Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 search n replace regular expressions

Author  Topic 

silverkitten
Starting Member

5 Posts

Posted - 2004-05-05 : 09:24:14
Hi all,

I am trying to change 'Char' to 'Nchar' in a generated SQL script using the Query analyzer, but i can't simply do a 'Replace All' since it replaces 'varchar' with'varnchar' and 'character' with 'ncharacter'.And my database script is too big to be updated manually. Is there any other way this can be done??Its driving me crazy!! Please Help!

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-05-05 : 09:26:01
yeah, put a space before char and Nchar...
Go to Top of Page

silverkitten
Starting Member

5 Posts

Posted - 2004-05-05 : 09:33:49
I've done that, but i've got statements like CONVERT(char....
and even some char's with two spaces before char or'+' or '['
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-05-05 : 09:41:29
So, if you know all the instances of character's you have before char, then do a few replaces...
Go to Top of Page

silverkitten
Starting Member

5 Posts

Posted - 2004-05-05 : 10:20:36
actually, its a bit more complicated than that...i have to get a solution which does that automatically, coz this technique will be extended in other scripts as well..and i'm not sure if they'd like to do the replaces manually
Go to Top of Page

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-05-06 : 14:48:41
Make 3 passes. Change all varchar to ~~, then change Char to Nchar, then change ~~ back to varchar.
Go to Top of Page
   

- Advertisement -