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)
 anyway around dynamic sql

Author  Topic 

kaus
Posting Yak Master

179 Posts

Posted - 2002-07-30 : 12:47:11
I've got a stored procedure:
CREATE PROCEDURE sp_spell_check
--@strManName as varchar(6),
@strMonth_ID as varchar(5),
@strMan_ID as varchar(5)
AS
-- ACCOMPLISHMENTS
IF EXISTS(
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'spell_check' AND table_schema = 'GM')
BEGIN
drop table [spell_check]
END

... etc
Is there any way I can use a variable for the table name without dynamic sql or exec(sql)?? I have a lot of other stuff to do with this table later in the procedure and it would be a huge dynamic sql

Any ideas greatly appreciated

Thanks

Pete

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-30 : 13:03:34
The only other way would be ...


declare @tablename varchar(256)
set @tablename = 'not_spell_check'
if @tablename = 'spell_check'
drop table spell_check

 


Jay White
{0}
Go to Top of Page

kaus
Posting Yak Master

179 Posts

Posted - 2002-07-30 : 13:47:52
Thanks - I think I found another way around the problem

Pete

Go to Top of Page
   

- Advertisement -