How to pass parameter to stored procedure?

Select * /*But don't use * in production! */ from sometable where somecolumn LIKE '%' + @department + '%.

Thanks, question answered! – George2 Jul 15 '10 at 11:58.

You concatenate the strings: select * from sometable where somecolumn LIKE '%' + @department + '%.

It's a variable, it goes outside the quotes. Select * from sometable where somecol like '%' + @department + '%' Or, more preferably, add the %s to the variable and just use it directly.

Try: select * from sometable where somecolumn LIKE '%' + @department + '%.

If you post code or XML, please highlight those lines in the text editor and click on the "code" button (101 010) on the editor toolbar to nicely format and syntax highlight it! – marc_s Jul 15 '10 at 13:23.

You could do something like this: select * from sometable where somecolumn LIKE '%' + @department + '%.

2 No it doesn't. This is not dynamic SQL – Martin Smith Jul 15 '10 at 11:50 You are correct sir. It was my knee jerk reaction for doing string concatenation in SQL.

Still have nightmares about some of the code I have seen. I removed the statement from the answer. – Josh Jul 16 '10 at 13:37 Good knee jerk reaction to have!

– Martin Smith Jul 16 '10 at 13:43.

Select * from sometable where CHARINDEX(@department,somecolumn)>0 You can also use the CHARINDEX function.

In the stored procedure, I need to pass parameter to a select-where-like statement. But seems my statement above does not work, any ideas how to pass parameter @department to like statement?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions