'exporting' a sql table

I have a script that runs daily and acquires all AD user information and other data, dumping into a sql table.
I want to setup another script that, once a month, will dump that same data into a 'history' table, but populate the first column with the date of the dump.
Source table being [user id],[first name],[last name].
I want the destination table to be
[record date],[user id],[first name],[last name].

Is there an easy sql command I can use to accomplish this?
SQL 2k8 on a 2k8 server, using powershell.
LVL 67
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, that is easy:
insert into destinationtable 
( [record date],[user id],[first name],[last name] )
select getdate(),  [user id],[first name],[last name]
 from sourcetable

Open in new window

sirbountyAuthor Commented:
For [record date], I would want today's date, because my script would perform this on the first day of each month.
Also, since I'm looping through 4-5 tables, is there a way to include the date, and then 'every column' in said table?

Something like
foreach table in table1, table2, table3
  insert into table values (getdate(), select columsn from table) )

Make sense?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
foreach is not possible "easily", though it is with dynamic sql

for the "all columns", so this requires your target table is indeed having FIRST the tstamp column, and then exactly all the other columns from the source table, yes like this:
insert into destinationtable 
select getdate(), *
 from sourcetable 

Open in new window

as you can see: don't mix up VALUES() and SELECT. it's either one or the other

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sirbountyAuthor Commented:
Cheers! :^)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.