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 2005 Forums
 Transact-SQL (2005)
 Copy table to another database? (Table Exists)

Author  Topic 

knockyo
Yak Posting Veteran

83 Posts

Posted - 2007-12-14 : 05:09:21
Actually i have the idea for the script, but it cannot execute. Here it is:

SELECT HOURLY_OUTPUT.* INTO HOURLY_OUTPUT IN DB_ARCHIVE.dbo FROM HOURLY_OUTPUT

the error is:
Incorrect syntax near the keyword 'IN'.


What it caused?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-14 : 05:11:41
quote:
Originally posted by knockyo

Actually i have the idea for the script, but it cannot execute. Here it is:

SELECT HOURLY_OUTPUT.*
INTO DB_ARCHIVE.dbo.HOURLY_OUTPUT IN DB_ARCHIVE.dbo
FROM HOURLY_OUTPUT

the error is:
Incorrect syntax near the keyword 'IN'.


What it caused?



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

knockyo
Yak Posting Veteran

83 Posts

Posted - 2007-12-14 : 05:21:41
quote:
Originally posted by harsh_athalye

quote:
Originally posted by knockyo

Actually i have the idea for the script, but it cannot execute. Here it is:

SELECT HOURLY_OUTPUT.*
INTO DB_ARCHIVE.dbo.HOURLY_OUTPUT IN DB_ARCHIVE.dbo
FROM HOURLY_OUTPUT

the error is:
Incorrect syntax near the keyword 'IN'.


What it caused?



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"



Thanks for fast reply.

if i want copy all the files older than 60days, how can it be done?

SELECT HOURLY_OUTPUT.*
INTO DB_ARCHIVE.dbo.HOURLY_OUTPUT
FROM HOURLY_OUTPUT
WHERE DT xxxxxxxxxx


Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2007-12-14 : 05:32:36
<= dateadd(dd,-60,datediff(dd,0,getdate()))
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-14 : 05:33:04
[code]SELECT HOURLY_OUTPUT.*
INTO DB_ARCHIVE.dbo.HOURLY_OUTPUT
FROM HOURLY_OUTPUT
WHERE dateadd(day, 0, datediff(day, 0, DT))< dateadd(day, 0, datediff(day, 0, dateadd(day, -60, getdate())))[/code]

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

knockyo
Yak Posting Veteran

83 Posts

Posted - 2007-12-14 : 05:45:14
quote:
Originally posted by harsh_athalye

SELECT HOURLY_OUTPUT.*
INTO DB_ARCHIVE.dbo.HOURLY_OUTPUT
FROM HOURLY_OUTPUT
WHERE dateadd(day, 0, datediff(day, 0, DT))< dateadd(day, 0, datediff(day, 0, dateadd(day, -60, getdate())))


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"



if the database table already exists at the DB_ARCHIVE, how to ensure that i will update into the table?
Go to Top of Page

knockyo
Yak Posting Veteran

83 Posts

Posted - 2007-12-14 : 10:20:38
How to copy from one table to another database? (Whether it exists or not i also need to insert records inside)??

hope can guide me!
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-12-14 : 23:15:00
Use data import/export wizard.
Go to Top of Page
   

- Advertisement -