Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Inserting default data into a working table.
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nechtmarrie
Starting Member

Belgium
24 Posts

Posted - 04/23/2013 :  06:05:13  Show Profile  Reply with Quote
Hi, iv got a problem here that i can't work out.

The situation is the following:

I have a table containing default data.

i need to insert this data in a working table witch also had 2 extra collums compared to the default data table. An id collum and a date collum.

I need to take the default data from the first table and insert it into the working table and also add a date to it.

Dous anyone have an idea on how to do this?
Thnx alot for your help!

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 04/23/2013 :  06:13:32  Show Profile  Reply with Quote
Is ID column having IDENTITY Propety?

INSERT INTO Working_Table(ColumnsListOtherThanID, DateColumn)
SELECT ColumnsList, GETDATE()
FROM Default_Table

--
Chandu
Go to Top of Page

nechtmarrie
Starting Member

Belgium
24 Posts

Posted - 04/23/2013 :  06:42:39  Show Profile  Reply with Quote
The tables are as following:

I'm trying to insert the data from Def_Planlijst Into Planlijst.

All data from the Def_Planlijst except for the id needs to be inserted into the Planlijst table and have the date when they where inserted filled in in the date collum.

The Vertrek_Tikklok collum can just be left blank for now.

Edited by - nechtmarrie on 04/23/2013 06:49:10
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 04/23/2013 :  07:00:15  Show Profile  Reply with Quote
INSERT INTO Planlijst (Datum, Nummer, Naam, Vetrek, Rit_1, Rit_3, Rit_3, TrailerNo1, TrailerNo2, TrailerNo3)
SELECT GETDATE(), Nummer, Naam, Vetrek, Rit_1, Rit_3, Rit_3, TrailerNo1, TrailerNo2, TrailerNo3
FROM Def_Planlijst


--
Chandu
Go to Top of Page

nechtmarrie
Starting Member

Belgium
24 Posts

Posted - 04/23/2013 :  07:03:02  Show Profile  Reply with Quote
If that works you made my day mate! :)
Testing it in my application now.
Ill let you know here if it works or not
Go to Top of Page

nechtmarrie
Starting Member

Belgium
24 Posts

Posted - 04/23/2013 :  07:24:53  Show Profile  Reply with Quote
Works like a charm :)
Thnx alot Chandu!
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 04/23/2013 :  07:26:05  Show Profile  Reply with Quote
quote:
Originally posted by nechtmarrie

Works like a charm :)
Thnx alot Chandu!


You are very welcome

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000