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.
| Author |
Topic |
|
thatzlim
Starting Member
6 Posts |
Posted - 2007-10-22 : 06:44:02
|
hi. i would like to create a sql string in my Stored Procedure.the sql string should look like this:Select * from User Where Name LIKE '%abc%' where abc is stored in an alias @namei wrote this:declare @sql nvarchar(50)set @sql = 'Select * from User Where Name LIKE '%' + @name + '%' how can i put the Quote sign before and after the % sign? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-10-22 : 06:46:46
|
use two quote signset @sql = 'Select * from User Where Name LIKE ''%' + @name + '%''' KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
thatzlim
Starting Member
6 Posts |
Posted - 2007-10-22 : 06:49:11
|
quote: Originally posted by khtan use two quote signset @sql = 'Select * from User Where Name LIKE ''%' + @name + '%''' KH[spoiler]Time is always against us[/spoiler]
thx a lot!!! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-22 : 06:58:38
|
quote: Originally posted by thatzlim hi. i would like to create a sql string in my Stored Procedure.the sql string should look like this:Select * from User Where Name LIKE '%abc%' where abc is stored in an alias @namei wrote this:declare @sql nvarchar(50)set @sql = 'Select * from User Where Name LIKE '%' + @name + '%' how can i put the Quote sign before and after the % sign?
orSelect * from User Where Name LIKE '%' + @name + '%'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|