Column names belong in the Select List. Table names belong in the From clause.
You can do the following.
create procedure simple
@col varchar(40)
as
declare @sql nvarchar(256)
Set @sql="select " + @col + " From tblname"
exec sp_executesql @sql
Go
Terry
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.