| Author |
Topic |
|
Rajee
Starting Member
12 Posts |
Posted - 2006-08-23 : 04:36:58
|
| Hi, i have a string variable and Iam trying to replace '|' with single quotes inside a stored procedure using Replace function of SQL Server.For example@Temp='abc|cde|'select @Temp=Replace(@Temp,'|',how to specify single quote as the second argument)ThanksRajee |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-08-23 : 04:40:03
|
select @Temp=Replace(@Temp,'|','''')Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
Rajee
Starting Member
12 Posts |
Posted - 2006-08-23 : 07:39:57
|
| Thanks for your reply. But i want to replace it with single quotes and not with two single quotes.Guess if i give u the exact requirement, it will be clear. Iam trying for something like thisqry='Select * from table where field1 like |s%|'+ ' and field2 != ||'Now i need to replace the | symbol with single quotes to make the query asSelect * from table where field1 like 'S%' and field2 !=''Then i need to execute the query asexec(qry)But how do achieve the replace step in between is my doubt.Thanks for your effort. |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-08-23 : 08:00:00
|
Somthing like this Declare @Qry varchar(100)set @qry='Select * from table where field1 like |s%|'+' and field2 != ||'Select @Qry = Replace(@Qry, '|','''')print @Qry Chirag |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-08-23 : 09:21:27
|
if you had even tried the thing i suggested you'd see that it does exactly what you wanted.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-08-23 : 09:32:44
|
quote: Originally posted by spirit1 if you had even tried the thing i suggested you'd see that it does exactly what you wanted.
opps i too over looked it. but i guess whole confusion, might not be aware that if you want to use single quoutes you need to replace it by 2 single quoutes .Chirag |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-08-23 : 09:35:29
|
the point is not in overlooking it.but just saying it doesn't work without even trying... that's really... well... nevermind Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-08-23 : 09:37:55
|
really... what???  Corey Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..." |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-08-23 : 09:45:43
|
don't push it Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
Rajee
Starting Member
12 Posts |
Posted - 2006-08-24 : 00:56:49
|
| Thanks. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-08-26 : 05:24:07
|
| To know the behaviour of single quote, run thisSelect '','''','''''','''''''',''''''''''MadhivananFailing to plan is Planning to fail |
 |
|
|
|