how store procdure call in cursor

Posted by Sagarp under Sql Server on 1/12/2010 | Views : 2190 | Status : [Member] | Replies : 1
Hi create produre in that proc i declare cusor and that cursor i have call another procdure it not working.i will try LDAP data insert in my table using custor pass LDAP address as paramete.reply how can do it?

this My proc
ALTER procedure [dbo].[proc_inser_data]
@adspath varchar(400)
as

declare @streetAddress nvarchar(250),@mobile int,@mail nvarchar(256),

@department nvarchar(256),

@sn nvarchar(256),@givenName nvarchar(256),@sAMAccountName nvarchar(256),@objectGUID uniqueidentifier



declare cur_insert_data cursor for


declare @adsiquery as nvarchar(4000)

set
@adsiquery='(
SELECT
*
FROM openquery
(ADSI, ''SELECT STREETADDRESS,MOBILE,MAIL,DEPARTMENT,SN,GIVENNAME,SAMACCOUNTNAME
FROM '''''+@adspath+'''''
WHERE
objectClass=''''user''''

'')


)'
begin

open cur_insert_data

fetch next from cur_insert_data

into

@streetAddress,@mobile,@mail,@department,@sn,@givenName,@sAMAccountName,@objectGUID



while @@fetch_status=0

begin



insert into table1

(address,Mobile,Email,Department,LastName,FirstName,AccountName)

values

(@streetAddress,@mobile,@mail,@department,@sn,@givenName,@sAMAccountName)



fetch next from cur_insert_data

into

@streetAddress,@mobile,@mail,@department,@sn,@givenName,@sAMAccountName,@objectGUID

end

close cur_insert_data

deallocate cur_insert_data

end
-------------------------------
proc_inser_data LDAP://DC=xxxx,DC=com'


-------------------------
Thanks
sagar

Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/



Responses

Posted by: Mehulthakkar1 on: 1/13/2010 [Member] Starter

Up
0
Down
Check the url http://www.dotnetfunda.com/forums/thread1194-how-store-procdure-call-in-cursor.aspx for answer.

Thanks
Mehul

Sagarp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response