Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Variable as a table name

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-06-18 : 11:36:29
Hi,

INSERT INTO [Raw].dbo.[@year]...

How to use a variable in such a statement above? i need to use variable as a table name, please help me.

thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2006-06-18 : 11:54:06
Have look at dynamic sql

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-19 : 02:09:11
Avoid passing object name as parameter
Read this
http://www.sommarskog.se/dynamic_sql.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -