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
 General SQL Server Forums
 New to SQL Server Programming
 same query gave me different results

Author  Topic 

ConnieXujuan
Starting Member

48 Posts

Posted - 2011-12-22 : 18:32:54
Hi there,

It is querying the same table. I logged in SQL server using windows login, and connected to a local instance (serverA) as well as another server instance (serverB); however, when I was running query:

SET NOCOUNT ON SELECT * FROM master.sys.database_principals WHERE type IN ('U')

on the local instance it gave me correct answer; but if I run query:

exec xp_cmdshell 'sqlcmd -S "ServerA" -Q "SET NOCOUNT ON SELECT * FROM master.sys.database_principals WHERE type IN (''U'')" -s "|" -W'

from the other instance (ServerB) I was connected to, it gave me a different answer.

anyone knows why that happend?

Thanks a lot!!!!

Connie

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-22 : 20:02:59
Please do not cross post. Locking this duplicate topic.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -