fskilnik
asked on
exec with string + variable
Hi there,
This code (below) does not work, although the sproc is perfect... I am SURE the problem is in the bold part. How should I correct it?
(It must insert a certain "Package Number 14" to the student with the email given)
Thanks!
(I know a variable would NOT be needed here, but with this correction I will put a WHILE thing to happen afterwards, therefore please help as requested.)
-------------------------- ---------- --------
USE [dbName]
GO
DECLARE
@return_value int,
@PackNumber int
SET @PackNumber = 14
EXEC @return_value = [dbo].[insMaterial_sproc]
@EmailLogin = N'emailgiven_thisOk',
@MaterialName = 'Package Number'+@PackNumber
SELECT 'Return Value' = @return_value
GO
This code (below) does not work, although the sproc is perfect... I am SURE the problem is in the bold part. How should I correct it?
(It must insert a certain "Package Number 14" to the student with the email given)
Thanks!
(I know a variable would NOT be needed here, but with this correction I will put a WHILE thing to happen afterwards, therefore please help as requested.)
--------------------------
USE [dbName]
GO
DECLARE
@return_value int,
@PackNumber int
SET @PackNumber = 14
EXEC @return_value = [dbo].[insMaterial_sproc]
@EmailLogin = N'emailgiven_thisOk',
@MaterialName = 'Package Number'+@PackNumber
SELECT 'Return Value' = @return_value
GO
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, this line doesn't make any sense:
You probably want this instead:
SELECT 'Return Value' = @return_value
You probably want this instead:
SELECT 'Return Value: ' + CAST(@return_value AS VARCHAR(40))
@MaterialName = 'Package Number'+str(@PackNumber)
ASKER
Thanks for you all. (Sorry for the delay, too busy...)
@BAKADY: error message - "Incorrect syntax near '+'."
@nemws1: PERFECT (and great explanation, thank you)
(On the SELECT matter: the original line was not changed, and it worked anyway, but thanks for this additional suggestion)
@vivekkumarSharma: error message - "Incorrect syntax near '+'."
@BAKADY: error message - "Incorrect syntax near '+'."
@nemws1: PERFECT (and great explanation, thank you)
(On the SELECT matter: the original line was not changed, and it worked anyway, but thanks for this additional suggestion)
@vivekkumarSharma: error message - "Incorrect syntax near '+'."
Open in new window
regards