When I try to execute the below procedure showing error 'INFORMATION_SCHEMA.COLUM'
create procedure data
(
@tablename varchar(50),
@userid int =''
)
AS
BEGIN
Declare @tsql varchar(50)
IF (@tablename = '')
SELECT * FROM tbl;
--ELSE
BEGIN
set @tsql = 'select Column_name
from INFORMATION_SCHEMA.COLUMNS
where Table_name like '+@tablename
exec(@tsql);
--set @tsql = 'select * from '+@tablename +' where userid ='+@userid
--exec(@tsql);
END
END