Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
help insert employee to #temp table all month...
help insert employee to #temp table all month
Rate Topic
Display Mode
Topic Options
Author
Message
midan1
midan1
Posted Saturday, January 05, 2008 6:24 PM
Old Hand
Group: General Forum Members
Last Login: Monday, July 28, 2008 8:42 AM
Points: 302,
Visits: 271
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
Post #439283
Jeff Moden
Jeff Moden
Posted Saturday, January 05, 2008 8:27 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 32,923,
Visits: 26,811
http://www.sqlservercentral.com/articles/Best+Practices/61537/
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #439299
David McFarland
David McFarland
Posted Saturday, January 05, 2008 11:12 PM
Right there with Babe
Group: General Forum Members
Last Login: Monday, December 08, 2008 8:42 AM
Points: 775,
Visits: 214
Whahuh?
Post #439315
Jeff Moden
Jeff Moden
Posted Sunday, January 06, 2008 12:01 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 32,923,
Visits: 26,811
It's a "hint" on how to post data... :P
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #439321
David McFarland
David McFarland
Posted Sunday, January 06, 2008 3:26 AM
Right there with Babe
Group: General Forum Members
Last Login: Monday, December 08, 2008 8:42 AM
Points: 775,
Visits: 214
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.
Post #439332
Kenneth.Fisher
Kenneth.Fisher
Posted Sunday, January 06, 2008 9:21 AM
Hall of Fame
Group: General Forum Members
Last Login: 2 days ago @ 1:16 PM
Points: 3,367,
Visits: 1,567
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 Fisher
I strive to live in a world where a chicken can cross the road without being questioned about its motives.
--------------------------------------------------------------------------------
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Link to my Blog Post -->
www.SQLStudies.com
Post #439342
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.