Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Steps for replacing in sql files

I need to update all varchar to nvarchar, text to ntext and char to nchar in some 300 .sql files stored on my disk. These files include stored procedures, triggers, functions, views etc. What is the best approach to achieve this.

like image 295
Chinjoo Avatar asked Nov 06 '22 06:11

Chinjoo


1 Answers

If you really want the safe way, you'd need to use a parser which actually understands the structure and only replaces these occurenses which do match.

I'm not sure if the effort to dive into it is worth it, but you could code something yourself. You could try and see if an opensource T-SQL parser can handle your files; one is part of the opensource bsn ModuleStore versioning toolset.

like image 148
Lucero Avatar answered Nov 09 '22 06:11

Lucero