Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a parametised Stored Proc?

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi All

I'm using Sybase so I'm hoping the syntax will be the same, but I can't get the following to work - Can anyone shed any light?

CREATE PROC TruncateTables (@TableName varchar(35))
AS
TRUNCATE TABLE @TableName
RETURN

error:
Server Message: Number 102, Severity 15
Procedure 'TruncateTables', Line 3:
Incorrect syntax near '@TableName'.

many thanks for any help
lou

 

Hi

I don't know Sybase, however if it is similar with SQL, I think you should change the code as follows:

CREATE PROC TruncateTables (@TableName varchar(35))
AS
DECLARE @strSql varchar(500)
SET @strSql='TRUNCATE TABLE ' + @TableName
EXEC @strSql
RETURN

I hope it is useful for you.


Uyen Chi
Software developer
 
Thanks for the replies.

Terry, I've tried posting in that forum before but it doesn't have many contributors so one may not get a reply for about a week.

I like this forum and I understand that SQLServer and Sybase used to be the same product a few moons ago so thought I'd post on here as there are alot of similiarites between them still.

lou

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top