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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Inserting default data into a working table.

Author  Topic 

nechtmarrie
Starting Member

24 Posts

Posted - 2013-04-23 : 06:05:13
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-23 : 06:13:32
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

24 Posts

Posted - 2013-04-23 : 06:42:39
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.
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-23 : 07:00:15
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

24 Posts

Posted - 2013-04-23 : 07:03:02
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

24 Posts

Posted - 2013-04-23 : 07:24:53
Works like a charm :)
Thnx alot Chandu!
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-23 : 07:26:05
quote:
Originally posted by nechtmarrie

Works like a charm :)
Thnx alot Chandu!


You are very welcome

--
Chandu
Go to Top of Page
   

- Advertisement -