Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
hissam78
Starting Member
14 Posts |
Posted - 2011-08-29 : 05:37:32
|
| Following code will insert the date one by one i want to insert one date 3 times e.g. 01-jun-2011 declare V_Counter DATE := '01-JUN-2011'; V_Counter1 DATE :='30-JUL-2011'; BEGIN WHILE v_Counter <= v_Counter1 LOOP INSERT INTO shift_schedule_final (date1) values (v_counter); v_Counter := v_Counter + 1; END LOOP; END; |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-08-29 : 05:46:00
|
| What is the business requirement? Why are you using cursor for this?MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-29 : 05:47:15
|
are you using Microsoft SQL Server ? ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
hissam78
Starting Member
14 Posts |
Posted - 2011-08-30 : 00:25:41
|
quote: Originally posted by madhivanan What is the business requirement? Why are you using cursor for this?MadhivananFailing to plan is Planning to failbasically i want to make a schedule for payroll. i need to insert the dates for three shifts one day three shifts it means three dates of same day i need to insert if any solution other than the above mentioned u have please tell me.
|
 |
|
|
hissam78
Starting Member
14 Posts |
Posted - 2011-08-30 : 00:27:13
|
quote: Originally posted by khtan are you using Microsoft SQL Server ? ? KH[spoiler]Time is always against us[/spoiler]yes my responsibility is to write the queries in sql for both the platforms sql server as well as oracle sql/plsql
|
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-30 : 00:38:08
|
I am not familiar with PS SQL syntax.For SQL Server, this is how you do itdeclare @dte dateselect @dte = '2011-07-01'insert into shift_schedule_final (date1) values (@dte), (@dte), (@dte) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|