Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 SQL Query help, please
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Astralis
Senior Member

USA
1218 Posts

Posted - 01 March 2011 :  11:02:30  Show Profile  Reply with Quote
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!

gpctexas
Junior Member

320 Posts

Posted - 02 March 2011 :  00:20:30  Show Profile  Visit gpctexas's Homepage  Reply with Quote
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.

ipgate 2.4.4 RC3
http://www.gpctexas.net/ipgate_v244.zip
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.13 seconds. Powered By: Snitz Forums 2000 Version 3.4.07