Stored procedure in SQL Server
Can I use only one stored procedure for many queries?
Like this:
SELECT @var开发者_C百科_name[0] from @table_name WHERE @con1 = @var_name[1] ;
You cannot do that. You could build the query dyamically with something like
EXEC('SELECT ' + @var_name + ' FROM ' + @table_name + ' WHERE ' + @Con1 + ' = ' + @var_name)
Be aware of potential performance and sql injection issues when doing this though.
精彩评论