Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 declare

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-07-16 : 03:42:54
HI,
This query below works on one machine which returns the domain name.
But on another machine it gives the error below.
Is there a setting in sql server to be set for this please?

--SQL
declare @DomainName varchar(128)
declare @hr int
declare @sysinfo int

--create a package object...
exec @hr = sp_OACreate 'ADSystemInfo', @sysInfo output
exec @hr = sp_OAGetProperty @sysInfo, 'DomainShortName', @DomainName output
select @DomainName

--error:

Msg 137, Level 15, State 2, Line 6
Must declare the scalar variable "@sysInfo".
Msg 137, Level 15, State 2, Line 8
Must declare the scalar variable "@sysInfo".

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-16 : 04:03:32
It seems like collations settings of the servers are different. You have used different case for variable in two places (i in declaration & I in assignment step). SO this might give error if you're using case sensitive collation
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-16 : 04:11:32
declare @sysInfo int




E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-07-16 : 04:52:57
Hi,
I figured it out.
I had to enable the ole automation in surface configuration for features.
Thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-16 : 05:03:02
That's another issue you have, whihc is NOT related to the error message depicted above.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-07-16 : 05:17:04
Well, the error message goes away and the query does indeed return a value.
Thanks
Go to Top of Page
   

- Advertisement -