February 26, 2009 at 2:20 am
Can anybody tell me how to replace a string with exact match in sql server.
Ex :
' Asset table has primary key named AssetID'
Here i have to replace word 'Asset' with 'Topic'.
But REPLACE function replaces both Asset and AssetID
Thanks in Advance,
Manohar V
February 26, 2009 at 2:35 am
There is no way to do like this but you can use sometrick like user space (or some special character) while replacing.
for example..
CREATE TABLE Asset(
AssetId INT,
AssetName)
here to replace 'Asset' table name you can use 'Asset(' while replacing.
Regards,
Nitin
February 26, 2009 at 2:47 am
Thanks Nitin,
But I want to replace all table names inside a procedure with schema prefix to it..
I have 2000 procedures in my database and i cant prefix manully..
So I am writing a function to replace the same..
Here I want to replace with exact match.... Any idea regarding this ...?
February 26, 2009 at 2:58 am
Then there is no way to do so using T-SQL. You can use managment studio to modify your SPs. Create Script for all SP in single file and use management studio's quick replace option and tick the match whole work option.
Regards,
Nitin
February 26, 2009 at 3:47 am
See also here.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply