Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 SQL Query help, please

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
Astralis Posted - 01 March 2011 : 11:02:30
I have a field that looks like "John And Mary". Notice how the 'and' is capitalized. I need to go through the database and find the fields that have that capitalized 'and' and make it lowercase. I know how to do this in a round-about way using ASP but wondered if there's a way to accomplish this using only MSSQL Server?

Thanks in advance!
1   L A T E S T    R E P L I E S    (Newest First)
gpctexas Posted - 02 March 2011 : 00:20:30
I have used something similar to this in the past when I needed to mass change email addresses at work for over 15k accounts.
Backup your data before running as this can produce unpredicted results if not handled right. Test using a test box first if you can.

First see if you can select the data you are needing to target
select columnname from table where columnname like '% And %' COLLATE SQL_Latin1_General_CP1_CS_AS



if it looks good then an update statement to find and replace the text should work. Keeping the space before and after the And should hopefully help keep names like Andrew Andrea etc from getting updated.

update table set columname = replace(columnname, ' And ' , ' and ') where columnname like '% And %' COLLATE SQL_Latin1_General_CP1_CS_AS


Some of the better db folks may be able to tweak or shed more light on this. If your server is using a different code page, then the collate statement will need to use the appropriate case sensitive code page for the server.

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000 Version 3.4.07