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 |
|
GiorgiZautashvili
Starting Member
4 Posts |
Posted - 2011-05-04 : 01:58:13
|
| Hi,is it possible to pass a piece of an SQL command as a text and evaluate it on the server with the rest of the command?Thank you |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-04 : 02:17:07
|
Sorry, don't quite understand what you want to do here.Can you explain further ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-05-04 : 02:22:37
|
| Perhaps a better approach would be to store that piece of SQL command in a Stored Procedure and call that SP from the application code :)CheersMIK |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-04 : 03:04:09
|
| Think you need to define what you mean by a piece of an sql command (statement?)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Swaynebell
Starting Member
8 Posts |
Posted - 2011-05-04 : 10:47:42
|
quote: Originally posted by GiorgiZautashvili Hi,is it possible to pass a piece of an SQL command as a text and evaluate it on the server with the rest of the command?
Yes. When bad guys do it, it's called SQL Injection I think Mik's idea of a stored procedure is a good way to go, although I also agree with Nigel that what you're trying to do isn't quite clear |
 |
|
|
GiorgiZautashvili
Starting Member
4 Posts |
Posted - 2011-05-06 : 04:01:12
|
| Hi and thanks to all,what I wanted to do is generate like clause on the client (code) side and then concatenate it with the rest, because the function is too big to write the whole thing on the client side, that's it :)e.g.var query = "theWholeFunction(@paramQuery)";var queryAsParameter = string.Join(" or ", from k in keys select "like '%' + " + k + " + '%'); command.Parameters.AddWithValue("paramQuery", queryAsParameter); |
 |
|
|
|
|
|
|
|