Fareeda Hussain

Fareeda Hussain

  • NA
  • 93
  • 92.4k

Showing error Invalid object name 'INFORMATION_SCHEMA.COLUM'

Dec 21 2016 5:19 AM
 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

Answers (1)