Must declare the scalar variable "@prodimg".

Posted by Rajujrk under Sql Server on 3/1/2010 | Views : 27790 | Status : [Member] | Replies : 4
Hai,

What it means?

Must declare the scalar variable "@prodimg".

I declared this variable in a stroed Procedure...

My Code is given Below..
[code]
CREATE PROCEDURE cloneTable (@users varchar(250)) AS
-- Add the parameters for the stored procedure here
DECLARE @categ varchar(150)
DECLARE @prod varchar(150)
DECLARE @proddoc varchar(150)
DECLARE @prodimag varchar(150)
DECLARE @prodsub varchar(150)
BEGIN
set @categ=@users + "_Catalog_Category"
set @prod=@users + "_Catalog_Product"
set @proddoc=@users + "_Catalog_Product_Document"
set @prodimg=@users + "_Catalog_Product_Image"
set @prodsub=@users + "_Catalog_Product_Subccat"
END

[/code]
But it shows the below error...
[code]
Msg 137, Level 15, State 1, Procedure cloneTable, Line 12
Must declare the scalar variable "@prodimg".
Msg 102, Level 15, State 1, Procedure cloneTable, Line 15
Incorrect syntax near '@categ'.
Msg 102, Level 15, State 1, Procedure cloneTable, Line 16
Incorrect syntax near '@prod'.
Msg 102, Level 15, State 1, Procedure cloneTable, Line 17
Incorrect syntax near '@proddoc'.
Msg 102, Level 15, State 1, Procedure cloneTable, Line 18
Incorrect syntax near '@prodimag'.
Msg 102, Level 15, State 1, Procedure cloneTable, Line 19
Incorrect syntax near '@prodsub'.
[/code]

Thanks & Regards

Rajkumar J



Responses

Posted by: Abhijit Jana on: 3/1/2010 [Member] [MVP] Bronze

Up
0
Down
Rajkumar,

There is a Typo :)

You declared prodImag as

	DECLARE @prodimag  varchar(150)


But, you are using it as,

set @prodimg =@users + "_Catalog_Product_Image"


Check the Bold Valriable. You are Declaring it as prodimag and using it as "prodimg " where "a" is missing That's why you are getting the error message. :)

Hope this will resolve your issue.

Cheers !
Abhijit

Rajujrk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajujrk on: 3/1/2010 [Member] Starter

Up
0
Down
Ya i corrected this problem,

But Still it shows the below error..
[code]
Incorrect syntax near '@categ'.

Incorrect syntax near '@prod'.

Incorrect syntax near '@proddoc'.

Incorrect syntax near '@prodimag'

Incorrect syntax near '@prodsub'.
[/code]

Thanks & Regards

Rajkumar J

Rajujrk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhijit Jana on: 3/1/2010 [Member] [MVP] Bronze

Up
0
Down
Yes, this is because of Syntx error Rajkumar.

Have a look,
CREATE PROCEDURE cloneTable (@users varchar(250)) AS

-- Add the parameters for the stored procedure here

DECLARE @categ varchar(150),
DECLARE @prod varchar(150),
DECLARE @proddoc varchar(150),
DECLARE @prodimag varchar(150),
DECLARE @prodsub varchar(150)

BEGIN


Cheers !
Abhijit

Rajujrk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 3/1/2010 [Member] [MVP] Silver

Up
0
Down
Hi Raj

Greetings

1. Move all your Declaration block next to the BEGIN as given below
2. Check Quoted_Identifier is OFF (or) Change the ( " ) to ( ' ).

CREATE PROCEDURE cloneTable
(
@users varchar(250)
) AS
BEGIN
-- Add the parameters for the stored procedure here
DECLARE @categ varchar(150)
DECLARE @prod varchar(150)
DECLARE @proddoc varchar(150)
DECLARE @prodimag varchar(150)
DECLARE @prodsub varchar(150)

set @categ=@users + '_Catalog_Category'
set @prod=@users + '_Catalog_Product'
set @proddoc=@users + '_Catalog_Product_Document'
set @prodimag=@users + '_Catalog_Product_Image'
set @prodsub=@users + '_Catalog_Product_Subccat'
END

Cheers


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Rajujrk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response