-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: CSharpMadhu
Message 1 in Discussion


I am trying to blank out all the tables from the database except for a particular 
table.  
The SP below gives the error 'Must declare the variable '@TableName' 
However if I comment the line delete from @TableName then it works fine. How do I make 
this work for delete?IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name 
= 'sproc_DeleteGenericData')
 BEGIN
  PRINT 'Dropping Procedure sproc_DeleteGenericData'
  DROP  Procedure  sproc_DeleteGenericData
 ENDGOPRINT 'Creating Procedure sproc_DeleteGenericData'
GO
CREATE Procedure sproc_DeleteGenericData
AS
DECLARE @TableName VARCHAR(50)
DECLARE Generic_tables_cursor CURSOR FOR
 select name from sysobjects where xtype='u' 
 
OPEN Generic_tables_cursor
 FETCH NEXT FROM Generic_tables_cursor into @TableName
 WHILE @@FETCH_STATUS = 0
 BEGIN  if(@TableName <> 'TBL_OLD_PRODUCTS')
  BEGIN

        print @TableName
        delete from @TableName  END
  FETCH NEXT FROM Generic_tables_cursor into @TableName
 END
CLOSE Generic_tables_cursor
DEALLOCATE Generic_tables_cursorGO 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to