Quantcast
Channel: Cursor help!?!
Viewing all articles
Browse latest Browse all 20

Cursor help!?!

$
0
0

Hello,

 

Alright I am querying through a linked server using an LDAP query. In the LDAP data store I get an error saying that it can't get more than 1000 records. I've done research and that is the default page size...ok i understand that. So I run a query in SQL and it errors on one of my profiles(I have 6 profiles), the one that has more than 1000 records. 

It only allows me to bring back 901 records, and how i know that is if I " select top 901 from openquery...." if I change it to 902 it errors.  

I dont know if a cursor is what i need but can I run a stored procedure with a cursor in it to grab say 200 or 500 records at a time.  So it'll loop through once and grab 500, then loop through it again and grab 500 then again 500 until it gets them all, but I need to learn how to let my procedure know which ones were already processed. At the end of my procedure i am just putting these results into a table i already have made.

I really don't know how many records are in the LDAP, atleast more than a 1000 but its no more than 5000. 

I will post my stored procedure, this procedure works for the first 5 profiles and fails on the last.  It works for the first 5 because there are only about 21 records between the 5, and the last has a ton of records.

The @PN is the profile name I am inserting in there from a function i have previously made. I did take out my LDAP connection info as well.

SET ANSI_NULLS ON
GOSET QUOTED_IDENTIFIER ON
GOALTERprocedure [dbo].[proc_SECCLASSNAMES] ASBEGINDECLARE @NAMECOUNT INTSET @NAMECOUNT = (SELECTCOUNT(*) FROM dbo.Profile_names)DECLARE @TRASH ASTABLE(PROFILENAME VARCHAR(MAX), ALREADYPROCESSED BIT)INSERTINTO @TRASHSELECT profiles, 'FALSE'FROM dbo.Profile_namesDECLARE @COUNTER INTSET @COUNTER = 0WHILE @COUNTER < @NAMECOUNT BEGINDECLARE @results varchar(1000)SET @results = 'lawson'DECLARE @PN VARCHAR(MAX)SET @PN = (SELECTTOP 1 PROFILENAME FROM @TRASH WHERE ALREADYPROCESSED = 'FALSE')PRINT @PNDECLARE @SELECT1 NVARCHAR(MAX)Set @Select1 = N'Select top 1000 g.cn
					From OpenQuery(ADSIGDC,' + '''' + 'Select cn
					From ''''' + 'LDAP://????/CN=SecClass,CN='+@PN+',CN=Profiles,O=lwsnSecData,cn=??,dc=????''''' +'Where lwsnLSCreatedBy = ''''' + @results + '''''' + '''' + ')g'INSERTINTO dbo.SecClass_NameEXEC(@SELECT1)UPDATE @TRASHSET ALREADYPROCESSED = 'TRUE'WHERE PROFILENAME = @PN		SET @COUNTER = @COUNTER + 1ENDEND

Any help would be greatly appreciated!

I am using SQL Server Mang studio 2008

 


Viewing all articles
Browse latest Browse all 20

Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Trending Articles


Break up Quotes Tagalog Love Quote – Broken Hearted Quotes Tagalog


Gwapo Quotes : Babaero Quotes


Libros para colorear


Mandalas de flores para colorear


Renos para colorear


Dromedario para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Love Quotes Tagalog


RE: Mutton Pies (mely)


El Vibora (1971) by Francisco V. Coching and Federico C. Javinal


Ang Nobela sa “From Darna to ZsaZsa Zaturnnah: Desire and Fantasy, Essays on...


Winx Club para colorear


Girasoles para colorear


Dibujos para colorear de perros


Toro para colorear


Lagarto para colorear


Long Distance Relationship Tagalog Love Quotes


Tropa Quotes


Mga Tala sa “Unang Siglo ng Nobela sa Filipinas” (2009) ni Virgilio S. Almario


Amarula African Gin





Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC