October 3, 2013 at 11:46 am
I would like to know why I can't run openrowset the way that system stored procedures do? For example, in sys.xp_logininfo, they use it. When I try to copy the part of the code from that SP for use in my code, it gives me the error:
Msg 156, Level 15, State 17, Line 16
Incorrect syntax near the keyword 'OPENROWSET'.
I just don't understand how it can work in the system SP, but I can't run the part of the code I want to use... please help.
October 3, 2013 at 6:09 pm
My suggestion is to show us the code that's giving the error. If possible the simplest case that reproduces the error.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
October 4, 2013 at 5:45 am
select'account name' = domain+N'\'+name,
'type' = convert(varchar(8), case when sidtype = 1 then 'user' else 'group' end),
'privilege' = 'admin',
'mapped login name' = domain+N'\'+name,
'permission path' = 'DOMAIN\GROUPNAME'
from OpenRowset(NetGroupGetMembers, 'DOMAIN\GROUPNAME')
That is the code.
October 4, 2013 at 6:21 am
kevin.unglesbee (10/3/2013)
I just don't understand how it can work in the system SP, but I can't run the part of the code I want to use... please help.
SQL Server 2005+ doesn't allow system rowset functions to be called directly from user code. So you need to either use the documented system SPs or write your own code using SQLCLR code.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply