May 13, 2008 at 11:58 am
I am trying to run the following query to retrieve a field based on the user id....
declare @userid varchar(6)
set @userid = '999999'
SELECT left(physicalDeliveryOfficeName,3),samAccountName FROM OPENROWSET( 'AdsDsoObject' ,
'Trusted_Connection=yes;ADSI Flag=0x11;Page Size=10000',
'SELECT samAccountName, givenName, sn, physicalDeliveryOfficeName
FROM ''LDAP://my.company.local''
WHERE objectClass=''Person''
AND objectClass = ''User'' and samAccountName = ''" + @userid + "'' ')
It keeps coming up null. I can substitute the parameter with ''999999'' and the query will work fine. It's not complaining about the syntax, but it is not reading correctly either.
May 13, 2008 at 12:45 pm
I don't think you can build the string in the OpenRowset command. Try building it as a string variable before, then use that.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply