| Author |
Topic |
|
Radhiga
Starting Member
35 Posts |
Posted - 2006-04-18 : 22:01:04
|
| Hello friends,im new to use Cursors. while (@@fetch_Status = 0)begin fetch Cur_ri into @COMPANY ,@STARTIME ,@ENDTIME SELECT @COMPANY @STARTIME, @ENDTIMEend close Cur_riDeallocate cursor...It is returning 10 records and all the 10 records ssq no is 1..is that mean when i capture in the .net front end will it return 10 difference datatable..is this behaviour right... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-04-18 : 22:03:56
|
Yes. your one SELECT statement will return as one result set so if you have 10 records, it will be 10 result set.Why do you need to use cursor ?you can just SELECT company, starttime, endtime from yourtable and it will return all 10 records in a single result set KH |
 |
|
|
Radhiga
Starting Member
35 Posts |
Posted - 2006-04-18 : 22:07:46
|
| Is it possible to select all the 10 records in one select statment... |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-04-18 : 22:08:56
|
yes, sql is designed to do just that...you can even do batch processing --------------------keeping it simple... |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-04-18 : 22:10:13
|
quote: Originally posted by Radhiga Is it possible to select all the 10 records in one select statment...
Yes. See my earlier post KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-19 : 03:09:48
|
| Radhiga, It seems that you are very much interested in using Cursors(from some of your posts)In most cases, that can be done very easily. Tell us what you are trying to do. Post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
Krankensteins
Starting Member
24 Posts |
Posted - 2006-04-19 : 05:07:52
|
| Whay not sou:Open cursorfetch Cur_ri into @COMPANY ,@STARTIME ,@ENDTIMEwhile (@@fetch_Status = 0)beginSELECT @COMPANY @STARTIME,@ENDTIMEfetch Cur_ri into @COMPANY ,@STARTIME ,@ENDTIMEend close Cur_riDeallocate cursor... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-19 : 05:22:06
|
| >>Whay not sou:What language is this?MadhivananFailing to plan is Planning to fail |
 |
|
|
Radhiga
Starting Member
35 Posts |
Posted - 2006-04-19 : 05:44:52
|
| THANKS MR.MADHIVANAN.MY REQUIRMENT IS LIKE THAT...NEED TO MAP TWO DIFFERENT TABLES WHICH DOESNT HAVE ANY MAPPING IN BETWEEN BUT WITH THE DATA WE CAN MAP IT..THAT'S Y I WANTED TO USE CURSOR..I HAVE FIXED THAT ONE THANKS. |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-04-19 : 05:45:10
|
quote: What language is this?
Latvian or other name i guess Lettish???If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-04-19 : 05:46:51
|
quote: Originally posted by Radhiga THANKS MR.MADHIVANAN.MY REQUIRMENT IS LIKE THAT...NEED TO MAP TWO DIFFERENT TABLES WHICH DOESNT HAVE ANY MAPPING IN BETWEEN BUT WITH THE DATA WE CAN MAP IT..THAT'S Y I WANTED TO USE CURSOR..I HAVE FIXED THAT ONE THANKS.
Can you post some sample data of both the tables ..?? and how are you going to map them ??If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
Krankensteins
Starting Member
24 Posts |
Posted - 2006-04-19 : 07:01:51
|
| {Sory} as follow:Declare T Cursor for select top 10 OrderID,CustomerID from dbo.OrdersDeclare @ID intDeclare @Cus nchar(5)Open Tfetch T into @ID ,@Cus while (@@fetch_Status = 0) begin SELECT @ID, @CUS fetch T into @ID ,@Cus end Close TDeallocate T |
 |
|
|
|