how store procdure call in cursor

Posted by Sagarp under Sql Server on 1/12/2010 | Views : 2123 | Status : [Member] | Replies : 4
HI

I have create one store procedure and that proc i have declare cursor for fetch one bye one record and insert in another table ,i have passmeter as ldap path i m trying ldap inforation insert in my table.check below proc tell what i do


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)



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



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

end

close cur_insert_data

deallocate cur_insert_data

end
---------------------------------------------
exec proc_inser_data LDAP://DC=xxx,DC=com

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



Responses

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

Up
0
Down
Can you explain more about your problem what exactly you want to do? either you want to call SP from Cursor or Cursor from SP

Thanks
Mehul Thakkar

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

Posted by: Sagarp on: 1/12/2010 [Member] Bronze

Up
0
Down
i have post total sp.how can pass ldap address

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

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

Posted by: Sagarp on: 1/13/2010 [Member] Bronze

Up
0
Down
i don't have send as paramer user, i m try to send paramer as ldap path

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

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

Login to post response