May 24, 2012 at 10:15 am
Hi,
I have table 'A' and wants to copy all data to table 'B'. Table 'B' is empty and all the contents from table 'A' will be copied over to table 'B'. Now the data from table 'A' will be copied to table 'B' every day. So for example : table 'A' has 10 rows then those 10 rows will be copied to table 'B'. Now table 'B' has one more column named date_time to track time. So this process will occur every day so the data copies every day and never gets deleted. So after 5 days table 'B' will have 50 rows and continues increasing.
Now this needs to run as a job. Can someone instruct me on how to create a job.
May 24, 2012 at 10:23 am
So what really is the question here? At first is seems you need help with an insert statement, then you say something about a job.
The sql statement is pretty simple.
insert tableb (columns)
select tablea.(columns), getdate()
from tablea
Setting up a sql job isn't too tough either. Make your code a stored proc. Then expan JOBS and create a new one. Just follow the steps, for this you probably one need 1 step.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 24, 2012 at 11:16 am
I am daring to suggest the Partition Switch (sliding window) here with the assumption that 10 rows that you mentioned are just a fake number and the table has voluminous data. Else please ignore it.
May 24, 2012 at 12:29 pm
No the above query fails. any idea???
May 24, 2012 at 12:43 pm
espanolanthony (5/24/2012)
No the above query fails. any idea???
From the details your provided? Nope.
If you actually want some help you need to help us to help you. Take a look at the link in my signature. To be honest, I am surprised at the lack of detail given that you have been around this site for awhile.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply