February 2, 2012 at 10:16 pm
I have a production database, in one table there is number of operations, this column contains '/' and and hence occurs escape sequence in c#.net,
Now i need to overcome this issue, when select statement executes, it replaces single '/' with double '//'
cam I have trigger for that or a computed text column formula. How to solve this?
The simplest way to solve this is Update this column by replacing double slashes. but I dont want to do that.
please help.
Thanks in advance.
February 2, 2012 at 10:47 pm
You can use a simple replace function to do that:
declare @MyString varchar(30)
set @MyString = '/abc/def/ghij/kl'
select @MyString, REPLACE(@MyString,'/','//')
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
February 2, 2012 at 10:56 pm
Yes, But where do I use this function, within trigger or anywhere else...??
Thats my question.
February 3, 2012 at 12:54 am
That depends. If you want to modify the string when you insert the data or when you update the data, you can use an "instead of trigger" to do it. Select doesn't have any trigger, so if you want to do it just for the select statement for one application, you can modify the select statement to include the replace function. Other alternatives are to have a view that formats the string or to have a computed column that formats it and use one of them in the select statement. Of course the programmer can also format the string in his application.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
February 3, 2012 at 8:58 pm
OK, got it.
Thanks.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply