Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy data from old table to new

Status
Not open for further replies.

mabis

Technical User
Jul 22, 2006
25
US
I run a small business and I am trying to pretend I know SQL2000. Any help would be appreciated.

I added a field RDI to an existing table MABIS CUSTOM in db SALESLOGIX. There are additional fields in MABIS CUSTOM. Therefore, when other fields are updated, the modify date changes. I need a unique modify date for field RDI (now name TF in the new table).

So, I created a new table named RDI with field name TF. I would now like to move a copy of the existing RDI field date (T, F data) and other required data from MABIS CUSTOM.RDI to RDI.TF.

I would like to leave the old data in the old table (MABIS CUSTOM). It causes me no problem to retain it.

I am unsure how to accomplish this. Summary. . .

Copy current data from MABIS CUSTOM including. . .
CONTACTID (string)
CREATEUSER (string)
CREATEDATE (date/time)
MODIFY USER (string)
MODIFY DATE (date/time)
RDI (string)

To RDI fields. . .
CONTACTID (string)
CREATEUSER (string)
CREATEDATE (date/time)
MODIFY USER (string)
MODIFY DATE (date/time)
TF (string) from MABIS CUSTOM.RDI

 
INSERT saleslogix.dbo.rdi (contactid, createuser, createdate, modifyuser, modifydate, tf)
SELECT contactid, createuser, createdate, modifyuser, modifydate, RDI)
FROM saleslogix.dbo.[mabis custom]

John
 
I know this is simple stuff for most. My novice-ness is showing.

1. Under the SELECT statement jrbarnett wrote, should there be a '(' before contactid?
2. Even when I add the '(' before contactid I still get the following error. Obviously, I dont know what is causing it.

Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ','.

Thank you for your help.


mabis
 
No.

The code posted by jrbarnett has an extra close parenthesis that you don't need.

Code:
INSERT saleslogix.dbo.rdi (contactid, createuser, createdate, modifyuser, modifydate, tf)
SELECT contactid, createuser, createdate, modifyuser, modifydate, RDI[s][!])[/!][/s]
FROM saleslogix.dbo.[mabis custom]

Code:
INSERT saleslogix.dbo.rdi (contactid, createuser, createdate, modifyuser, modifydate, tf)
SELECT contactid, createuser, createdate, modifyuser, modifydate, RDI
FROM saleslogix.dbo.[mabis custom]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top