Friday 15 February 2013

sql server - Use result as table name for select statement in mssql -


To select the result of a statement as a table name for any statement I was trying the following questions @ Tblname is not the result of a string result that I want:

  declared @tblname varchar (50) declared @sql nvarchar (1000) declared @ stand varchar (20) set @stand = 'test' Set @sql = 'test_products' in the one of the wap attribute_tables atbl (atbl.id = wap.colors_tbl_id) where wap.dept = @stand' exec_sp_executesql @sql execute @ test_products select from @ temp = atbl.table_name, n '@s Tand Navaracha (20), @ Temp Narrupar (50) Opput ', @ stand = @ stand, @temp = @tblname OUTPUT declared @Test Navarachar (30) Set @ Teist = @Teban Set @SxL =' Select * @ Tblname SQLite  concatenate  String:  
  ... set @sql = 'SELECT * FROM' + @tblname execute (@sql)   

table name, as well as column Names can not be parameterized.

No comments:

Post a Comment