[posted and mailed, please reply in news]
Saiyou Anh (wa***@alexian.net) writes:
I want to pass a column name, sometimes a table name, to a stored
procedure, but it didn't work. I tried to define the data type as
char, vachar, nchar, text, but the result were same. Any one know how
to get it work?
So why do you need to do this?
While this is possible to do this, you might essentially be throwing
out the baby with the bathtub and loose most of the advantages of
stored procedures. Often this is a token of bad design.
Anyway, I have a longer article on my web site that shows you how to do
it - and why you probably shouldn't.
http://www.sommarskog.se/dynamic_sql.html
--
Erland Sommarskog, SQL Server MVP,
so****@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp