Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Error 137 - you must declare the scalar variable


Error 137 - you must declare the scalar variable

Author
Message
dokledon
dokledon
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 257
Hi,

I'm running a script against 16 registered servers (6 SQL 2000, 4 SQL 2005, 6 SQL 2008R2) within the same connection.

It works well, except for 2 of 6 the SQL 2008R2.

I receive the error: Error 137 - you must declare the scalar variable.

The script starts like that:

Declare @datefull datetime
Declare @datelog datetime

Set @datefull = '01/05/13 23:12:00.500'
Set @datelog = '28/09/13 14:05:23.100'

Select .....
From ....
GO


I can't understand why those 2 SQL 2008R2 return this error, as it is the same script for all registered servers.

Could it be an Instance configuration ?

Thanks,
Dok
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45390 Visits: 39941
Without seeing the rest of the proc, error line number, etc, it's difficult to tell but it could be an artifact later in the code caused by the date format or language settings and the fact that it appears that your dates are in the dd/mm/yyyy format. Total shot in the dark, though.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
patrickmcginnis59 10839
patrickmcginnis59 10839
SSC Eights!
SSC Eights! (887 reputation)SSC Eights! (887 reputation)SSC Eights! (887 reputation)SSC Eights! (887 reputation)SSC Eights! (887 reputation)SSC Eights! (887 reputation)SSC Eights! (887 reputation)SSC Eights! (887 reputation)

Group: General Forum Members
Points: 887 Visits: 5111
dokledon (8/2/2013)
Hi,

I'm running a script against 16 registered servers (6 SQL 2000, 4 SQL 2005, 6 SQL 2008R2) within the same connection.

It works well, except for 2 of 6 the SQL 2008R2.

I receive the error: Error 137 - you must declare the scalar variable.

The script starts like that:

Declare @datefull datetime
Declare @datelog datetime

Set @datefull = '01/05/13 23:12:00.500'
Set @datelog = '28/09/13 14:05:23.100'

Select .....
From ....
GO


I can't understand why those 2 SQL 2008R2 return this error, as it is the same script for all registered servers.

Could it be an Instance configuration ?

Thanks,
Dok


You could also doublecheck that these two servers don't have one of those "case sensitive" collations. If it had a case sensitive collation and you aren't consistant with your naming of variables (the declaration has all lowercase and subsequent use of that variable maybe has an uppercase spelling), this could lead to these specific servers complaining while others successfully run.

Just a possibility you might want to eliminate!

to properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
dokledon
dokledon
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 257
Thanks to Jeff and Patrick for their answers.

It was indeed a collation problem, as one of the variable was using Upper case and was called with Lower case.

Dok.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search