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
 Passing table name to the Openxml method

Author  Topic 

mayank15
Starting Member

1 Post

Posted - 2007-07-08 : 03:03:15
I want to pass the table name as a variable

Declare @tbl varchar(30)
set @tbl = 'DB.dbo.Set'
declare @sql nvarchar(200)
set @sql =
'select * from OPENXML(@xmldoc,'DB.dbo.Site',2) with' + @tbl + ''
exec(@sql)

Please help me with the correct syntax.
Mayank

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-08 : 04:37:51
Please read about dynamic sql first
http://www.sommarskog.se/dynamic_sql.html


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -