Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Macro Substitution
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01059687
Message ID:
01059690
Vues:
9
>Hi,
>
>I have the following stored procedure:
>
>CREATE PROCEDURE ACC_usp_Next_Number @cTableName char(40),@cField AS CHAR(40),@iNext int OUTPUT AS
>
>DECLARE @cSQLString VARCHAR(256)
>
>SET @cSQLString = 'SELECT @iNext = MAX('+@cField+') FROM '+RTRIM(@cTableName)
>
>EXEC(@cSQLString)
>
>RETURN @iNext
>GO
>
>
>I get the error "Must declare the variable '@iTest'.". Basically I would like to get the next number of the table and field that I pass. Why is it telling me to declare @iTest if I'm passing it? Does anyone know of a better way to accomplish this?
>
>Thanks.
CREATE PROCEDURE ACC_usp_Next_Number @cTableName char(40),@cField AS CHAR(40),@iNext int OUTPUT AS
DECLARE @cSQLString VARCHAR(256)

DECLARE @iNext integer -- or whatever type is @cField

SET @cSQLString = 'SELECT @iNext = MAX('+@cField+') FROM '+RTRIM(@cTableName)
EXEC(@cSQLString)
RETURN @iNext
GO
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform