Hi I have the fallowing
#Tabel1
UserName Information1
Information2 Information3
aaaa ab
cv de
bbbb ae
rf cs
dddd et
hh rt
bbbb ze
rt sw
Query
declare @name nvarchar(100)
declare @sql nvarchar(max)
set @name = 'aaaa'
set @sql=
'SELECT * FROM OPENQUERY (
ADSI,
''SELECT
samaccountname,
RBCountryISOCode , Department, company
FROM ''''LDAP://rbeurdom01/DC=rbdom,DC=rbroot,DC=net''''
WHERE
objectClass = ''''user''''
and objectCategory = ''''person''''
and samaccountname = ''''' + @name + '''''
'')'
exec dbo.sp_executeSQL @sql
I want an result of #TableReslt with
UserName Information1
Information2 Information3
RBCountryISOCode Department
company
aaaa ab
cv de DE
Market Company1
bbbb ae
rf cs US
Sales Company2
dddd et
hh rt BE
Market Company1
bbbb ze
rt sw US
Sales Company2
How do i do it? Thank you