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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Execute command

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-11-16 : 10:02:35
mala writes "I have to pass table name dynamically & have to check whether that table exists. For that If I use following code I am getting error. But it works for simple query not with IF EXISTS. Please help.

eg.
declare @v_tab varchar(300)
declare @v_tabname varchar(8)
declare @v_cal varchar(8)
set @v_tabname="upload"
set @v_cal='"aaaaa"'
select @v_tab = 'if exists(select i_code from '+@v_tabname + ' where i_code='+@V_cal+')'
exec (@v_tab)"
   

- Advertisement -