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 |
thrashead
Starting Member
3 Posts |
Posted - 2009-04-07 : 12:34:40
|
Hi im new here also this is my first message. So before it i want to say 'Hello World' :DMy question is, I use parameter in my sql command like this;select FirstName, LastName from person.contact where FirstName like '%@name%'@name is a parameter but when i use this i cannot get any data. but if i don't use parameter i get the datas. so i think we cannot use parameter like that. Can we?I'll wait for your answer. Thank you. |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-04-07 : 12:51:28
|
There is nothing something wrong with the sql code you posted. I suspect your asp.net app is sending something other that what you expect. User Sql Profiler to capture the actual call that is being made.EDIT:Be One with the OptimizerTG |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-07 : 13:26:42
|
select FirstName, LastName from person.contact where FirstName like '%' + @name + '%' E 12°55'05.63"N 56°04'39.26" |
|
|
thrashead
Starting Member
3 Posts |
Posted - 2009-04-07 : 13:27:31
|
exec sp_executesql N'select FirstName, LastName from person.contact where FirstName like ''%@name%''',N'@name nvarchar(1)',@name=N'A'this is the code shown in profiler. also i tried this code by using sql server, i got a table had no result. |
|
|
thrashead
Starting Member
3 Posts |
Posted - 2009-04-07 : 13:29:49
|
select FirstName, LastName from person.contact where FirstName like '%' + @name + '%'this code is ok. thank you very much really. I think in code behind i must think the string as using in the sql server. |
|
|
|
|
|