January 5, 2008 at 6:24 pm
help insert employees to #temp table all month
and loop insert until the last employee
i have table employee
empid name
--------------------
1111 xxxx
2222 yyyy
-----------------------
now i need to insert all the employee for all month to one table
like this
insert empid=1111
to tb_temp
start day=01/02/2008
end day = 11/02/2008
val=1
NEXT
insert empid=2222
to tb_temp
start day=05/02/2008
end day = 20/02/2008
val=5
NEXT
....
and after i need to get the employee in the temp_table
BUT WITH condition
and only on Saturday + Sunday
i need to change the val !
if 'Saturday'
than val=55
if 'Sunday'
than val=99
if 'monday'
Normal processing
if 'tuesday'
Normal processing
if 'wednesday'
Normal processing
if 'thursday'
Normal processing
if 'Friday'
Normal processing
.........................
required output result
empid date val day name
-----------------------------------
1111 1/2/2008 1 Tuesday
1111 2/2/2008 1 Wednesday
1111 3/2/2008 1 Thursday
1111 4/2/2008 1 Friday
1111 5/2/2008 99 Saturday
1111 6/2/2008 55 Sunday
1111 7/2/2008 1
1111 8/2/2008 1
1111 9/2/2008 1
1111 10/2/2008 1
1111 11/2/2008 1
2222 6/2/2008 55 Sunday
2222 7/2/2008 5 Monday
2222 8/2/2008 5 Tuesday
2222 9/2/2008 5 Wednesday
2222 10/2/2008 5 Thursday
2222 11/2/2008 5 Friday
2222 12/2/2008 99 Saturday
2222 13/2/2008 5
2222 14/2/2008 5
2222 15/2/2008 5
2222 16/2/2008 5
----------------
TNX
January 5, 2008 at 8:27 pm
http://www.sqlservercentral.com/articles/Best+Practices/61537/
--Jeff Moden
Change is inevitable... Change for the better is not.
January 5, 2008 at 11:13 pm
Whahuh?
January 6, 2008 at 12:01 am
It's a "hint" on how to post data... 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
January 6, 2008 at 3:26 am
My "Whahuh?" was directed at the OP, not your link. 🙂
I can't tell what they want to accomplish no matter how many times I read it.
January 6, 2008 at 9:21 am
Ok I'm going to make a wild guess and say they are looking for a CASE statement to determine the weekday.
empid date val day name
-----------------------------------
1111 1/2/2008 1 Tuesday
1111 2/2/2008 1 Wednesday
1111 3/2/2008 1 Thursday
1111 4/2/2008 1 Friday
1111 5/2/2008 99 Saturday
1111 6/2/2008 55 Sunday
So
CASE WHEN [day name] = 'Saturday' THEN 99 WHEN [day name] = Sunday THEN 55 ELSE 1 END
At least I think that is part of it.
Although if I were you I would re-post using Jeff's Best Pratcties for posting doc. It would make things alot easier to understand.
Kenneth FisherI was once offered a wizards hat but it got in the way of my dunce cap.--------------------------------------------------------------------------------For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]Link to my Blog Post --> www.SQLStudies.com[/url]
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply