Of course, it won't work since you will have to use D-Sql here.declare @sql varchar(8000)set @sql = 'insert into ' + @tblnames + '(id,name,tblname,dbname) select id,name,' + @name + ',''pubs'' from ' + @dbname + '..syscolumns where id=' + convert(varchar(10), @id)exec(@sql)
But I strongly advise you against following such practices. Why you need this kind of query? Why table name and DB name is required to be dynamic?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"