Educational Materials like Computer, engineering, software and Property , Entertainment: How to use cursor in stored procedure in MS SQL
Custom Search

Subscribe Now: Feed Icon

January 10, 2012

How to use cursor in stored procedure in MS SQL

Axapta Code solutions   Education and Entertainments  Earn Money its Real  Experience of knowledge  Imortant Weblink collections   Fun and Entertainment   God thoughts   Get Ways to Invest your money   Products overview and details

How to use cursor in stored procedure in MS SQL

DECLARE @ testcols1 AS varchar(30)
DECLARE @ testcols2 AS varchar(30)
DECLARE c_Cursor CURSOR FOR SELECT Col1, Col2 from Customer
OPEN c_ Cursor
FETCH NEXT FROM c_ Cursor INTO @ testcols1, @ testcols2
WHILE @@FETCH_STATUS=0 
BEGIN 
      Exec ('select ' + @ testcols1 + ' , ' + @vcol2 + ' from CustE)
      FETCH NEXT FROM c_ Cursor INTO @ testcols1, @ testcols2
END 
CLOSE c_ Cursor
DEALLOCATE c_ Cursor

0 comments:

Post a Comment

Follow by Email

Video Bar

Loading...

Followers

Educational Materials like Computer, engineering, software and Property , Entertainment

Recent Visitors

Active Search Results
Wink Bingo | Slots Tips | Football manager 2010 | blackjack free | Poker Stars
Submitdomainname.com