| |

VerySource

 Forgot password?
 Register
Search
Author: lehmann

Cursor building will not be done, wait online, thank you ~

[Copy link]

0

Threads

35

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-6-29 12:00:01
| Show all posts
--Usage of cursor
DECLARE pivot_Cursor CURSOR FOR
select a from pivot
OPEN pivot_Cursor

FETCH NEXT FROM pivot_Cursor into @a
WHILE @@FETCH_STATUS = 0
BEGIN
...
FETCH NEXT FROM pivot_Cursor into @a
END

CLOSE pivot_Cursor
DEALLOCATE pivot_Cursor
Reply

Use magic Report

0

Threads

35

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-6-29 13:30:01
| Show all posts
--Usage of cursor
DECLARE pivot_Cursor CURSOR FOR
select a from pivot
OPEN pivot_Cursor

FETCH NEXT FROM pivot_Cursor into @a
WHILE @@FETCH_STATUS = 0
BEGIN
...
FETCH NEXT FROM pivot_Cursor into @a
END

CLOSE pivot_Cursor
DEALLOCATE pivot_Cursor
Reply

Use magic Report

4

Threads

27

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 Unknown

 Author| Post time: 2020-6-29 21:30:01
| Show all posts
:)
I just don’t know how to read data line by line,
Read the specific column or columns of data read into the variable,
Reprocess
I have seen the definition
Reply

Use magic Report

0

Threads

35

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-6-30 10:15:01
| Show all posts
DECLARE pivot_Cursor CURSOR FOR
select a, b from pivot--This is the result set to be traversed with the cursor
OPEN pivot_Cursor

FETCH NEXT FROM pivot_Cursor into @a,@b--This is to get the first record, and assign the record column to the variable
WHILE @@FETCH_STATUS = 0--This is to determine whether there is any data behind
BEGIN
...--This is dealing with
FETCH NEXT FROM pivot_Cursor into @a--this is the next record
END

CLOSE pivot_Cursor
DEALLOCATE pivot_Cursor
Reply

Use magic Report

4

Threads

27

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-7-1 20:30:01
| Show all posts
I want to get all records
Reply

Use magic Report

0

Threads

6

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-6 21:30:02
| Show all posts
It is best not to use cursors
Reply

Use magic Report

0

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-6 23:00:01
| Show all posts
mark
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list