can i pass the name of the table and the "order by" column name to stored procedure?
i tried the simple way
(@.tablename varchar and then "select * from @.tablename)
but i get error massesges. the same for order by...
what is the right syntex for this task?
You have to use dynamic SQL for this task, unfortunately. You have to create a character string in your sproc that puts together the SQL statement and then you have to call exec(@.sql) on it.
Example:
@.sql = 'SELECT * FROM ' + @.tableName
exec(@.sql)
|||well, i just started to use stored procedure, i think that i will leave dynamic sql to later on...
No comments:
Post a Comment