Reputation: 9
I have this:
DECLARE @Client NVARCHAR(25),
@sqlStr NVARCHAR(MAX);
SET @sqlStr = 'INSERT INTO #GetDisplayName (displayName) SELECT displayName FROM OPENROWSET
(''ADSDSOObject'', ''adsdatasource''; ''mxi\santos'';''Consultant1'',
''SELECT displayName FROM ''''LDAP://mxiadsrv/DC=mxi,DC=com''''
where sAMAccountName=''''' + @Client + ''''''')'
SET @sqlStr = REPLACE(REPLACE(REPLACE(@sqlStr,' ',' %'),'% ',''),'%','')
And in one of my loops I get:
INSERT INTO #GetDisplayName (displayName) SELECT displayName FROM OPENROWSET ('ADSDSOObject', 'adsdatasource'; 'mxi\santos';'Consultant1',
'SELECT displayName FROM ''LDAP://mxiadsrv1/DC=mxi,DC=com''
where sAMAccountName=''fallot ''')
The problem is the extra space in the sAMAccountName=''fallot ''') section
How can I avoid this? Thanks so much!
Upvotes: 1
Views: 40