all groups > sql server programming > april 2004 >
You're in the

sql server programming

group:

addressing a table indirectly



Re: addressing a table indirectly J. M. De Moor
4/3/2004 10:14:32 AM
sql server programming: You should probably Google questions like this. It gets answered a LOT in
this NG.

EXEC ('SELECT * FROM ' + @table_name);

Joe De Moor

PS. This is considered poor practice.

addressing a table indirectly toylet
4/3/2004 11:10:36 PM

How could I do something like this without dynamic SQL?

declare @table_name="shippers";
use northwind;
select * from @table_name;


--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
Re: addressing a table indirectly Keith Kratochvil
4/9/2004 2:26:32 PM
Read this excellent article:
The Curse and Blessings of Dynamic SQL
http://www.algonet.se/~sommar/dynamic_sql.html

--=20
Keith


[quoted text, click to view]
Re: addressing a table indirectly Mario Splivalo
4/9/2004 5:17:36 PM
[quoted text, click to view]

Why is this consideret a poor practice? I can think of some situations where
above usage is appreciated.

Mike
--
"I can do it quick. I can do it cheap. I can do it well. Pick any two."

Mario Splivalo
AddThis Social Bookmark Button