SQL Clone
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
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 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 Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221396 Visits: 42002
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
patrickmcginnis59 10839
patrickmcginnis59 10839
SSCarpal Tunnel
SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)

Group: General Forum Members
Points: 4464 Visits: 5925
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
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 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