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
 General SQL Server Forums
 New to SQL Server Programming
 Inserting Data

Author  Topic 

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2007-03-02 : 08:42:17
I want to insert data into a table Period without overwriting old data

SELECT Period1Start,Period1End, 1 as PeriodType, SuperAreaID,Period1Price INTO Period
FROM EUBoatsPreferences2 where SuperAreaID = 71

go

SELECT Period1Start,Period1End, 2 as PeriodType, SuperAreaID,Period1Price INTO Period
FROM EUBoatsPreferences2 where SuperAreaID = 72

SQL 2005 IS SAYING
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'Period' in the database.

Which I know, I just want to append the data, pls help

If it is that easy, everybody will be doing it

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-02 : 08:45:38
1. Don't use SELECT...INTO for large data copy operations, it results in placing locks on system tables for the duration of copy
2. Create table first and then insert data using INSERT INTO...SELECT statement.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2007-03-02 : 08:54:58
Thank u people, I have solved it

INSERT INTO Period
(PeriodStartDate,PeriodEndDate,PeriodType,SuperAreaID,PeriodPrice)
select Period1Start,Period1End, 6 as PeriodType, SuperAreaID,Period1Price
from EUBoatsPreferences2 where SuperAreaID = 76

If it is that easy, everybody will be doing it
Go to Top of Page
   

- Advertisement -