SQL Server - select into from statement? -


i have query in sql server:

select column table_53; 

now, want 53 table, want this:

select column table_(select id table2); 

is there way in sql server?

you need dynamic sql query here.

declare @sqlquery = 'select column table_(';  set @sqlquery = @sqlquery + 'select id table2)';  exec (@sqlquery) 

note :- 1 of cons of using dynamic sql query sql injection. suggest have better table structure or try used parameterized query.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -