Author |
Topic |
raaj
Posting Yak Master
129 Posts |
Posted - 2011-01-30 : 17:02:24
|
Hi Guys,I am having a table named 'Employee' and it has many columns.This table gets data from different other tables.I have 3 insert select statements which populates this table and when i schedule this query as a job, I want to run those queries in sequential order.-- step 1:Insert into Employee (col1,col2,col3)Select col1,col2,col3 from DetailTable-- step 2:Insert into Employee (col4,col5,col6)Select col4,col5,col6 from HistoryTable-- step 3:Insert into Employee (col7,col8)Select col7,col8 from PersonnelTableNow I want to create a job with the above queries which runs every 3 hrs.Now what I want is :When I create a job with above T SQL statements, Do they run in the same order as I have written the queries?Like first I want to run the step 1 query and then step 2 query and then step 3 query?Do I need to add any extra clause to make them run one after another?any ideas???Raaj. |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2011-01-30 : 17:11:40
|
The go in the order you specify, and/or the order written. If you actually tried setting up an agent job, this would be fairly easy to identify. You can do it 3 separate job steps, or in 1 T-SQL step inthe order you indicate. The run in the order from top to bottom. You could also do it in one stepINSERT INTO employee (col1,col2,col3,col4,col5,col6,col7,col8)SELECT col1,col2,col3, NULL, NULL,NULL, NULL,NULLUNION ALLSELECT NULL, NULL,NULL,col4,col5,col6, NULL,NULLUNION ALLSELECT NULL, NULL,NULL, NULL,NULL,NULL,col7,col8One is left to wonder what possible benefit those queries have in the final result. Every time it runs, Columns 1-6 will be empty for every record in the personnel table. Also..populating the employee table from personnel table every 3 hours might be a bit redundant unless you have really high turnover. ;) . I am sure your query was more for demonstration...but still...perhaps you lay out what you are actually trying to do, and we can like give better suggestions. Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
|
|