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 2000 Forums
 Transact-SQL (2000)
 copying data from one table to another

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-15 : 10:02:03
AJ writes "I have two tables which are exactly alike. What I want to do is copy an entire column(the descriptions)from one table and put that information into the other table's description column where the ID matches up. Is there a way to go about doing this?
Thanks,
AJ"

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-03-15 : 10:27:39
UPDATE table1
SET column(the descriptions in table 1) = t.column (the descriptions from table 2)
FROM table2 t, table1 s
WHERE t.id = s.id

This basic example in avaiable in BOL under Title: UPDATE Location: Transact-SQL Reference Rank: 41.

Jeremy

Go to Top of Page

morningsidebooks
Starting Member

4 Posts

Posted - 2002-03-18 : 10:37:29
The table that I want the descriptions to be put into is called ebooks, and the table that I want the descriptions to come from is called ebooks2 and the "ID" is called BOOK. This is what I typed in.
UPDATE ebooks
SET DESCRIPTION = t.DESCRIPTION
FROM ebooks2 t, ebooks s
WHERE t.BOOK = s.BOOK;
Was that correct?
I got ERROR 1064 You have an error in your SQL syntax near 'FROM ebooks2 t, ebooks s
WHERE t.BOOK = s.BOOK' at line 3

Go to Top of Page

Nazim
A custom title

1408 Posts

Posted - 2002-03-19 : 00:21:43

UPDATE t SET t.DESCRIPTION = s.DESCRIPTION
FROM ebooks t
inner join ebooks2 s
on t.book=s.book



HTH




--------------------------------------------------------------
Go to Top of Page

morningsidebooks
Starting Member

4 Posts

Posted - 2002-03-19 : 11:32:06
The last post did not work either
I got the same error, "Error 1064 You have an error in your SQL syntax near 'FROM ebooks t innerjoin ebook2 s on t.BOOK=s.BOOK
Hopefully there is another way to go about doing this.

Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-19 : 13:27:16
what are you using?

SQL Server error 1064 is 'A filegroup cannot be used with log files.'.

quote:

I got the same error, "Error 1064 You have an error in your SQL syntax near 'FROM ebooks t innerjoin ebook2 s on t.BOOK=s.BOOK
Hopefully there is another way to go about doing this.





setBasedIsTheTruepath
<O>
Go to Top of Page

morningsidebooks
Starting Member

4 Posts

Posted - 2002-03-20 : 10:53:26
I log onto the server using telnet and type all my commands in there once i'm logged in.

Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-20 : 11:24:44
right ... are you using SQL Server I mean? the error code coming back from whatever SQL client you're using does not match the documented error message that SQL Server would send.

Given that you're using telnet, i'll hazard a guess that you're connecting to ... oracle?

setBasedIsTheTruepath
<O>
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2002-03-20 : 15:33:50
Worse! mySQL

Go to Top of Page

chrispy
Posting Yak Master

107 Posts

Posted - 2002-03-20 : 18:26:25
Worse yet! MS SQL on a WIN 2k box with Telnet enabled.

Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-03-20 : 19:12:39
I believe the oracle form would be:
Update ebooks t
set t.desc = (
select s.desc
from ebooks s
where s.book = t.book
)

from memory - but it's been a looooooooooooooooooooong time

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

morningsidebooks
Starting Member

4 Posts

Posted - 2002-03-22 : 09:54:09
It is a MySQL Server runnuing Ver 11.16 Distrib 3.23.49

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-22 : 09:58:06
Head over to http://dbforums.com and check their mySQL forum, they will probably be able to help you with this one.

Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-22 : 09:58:59
Then, unfortunately, you're in the wrong place ...

quote:

It is a MySQL Server runnuing Ver 11.16 Distrib 3.23.49



setBasedIsTheTruepath
<O>
Go to Top of Page
   

- Advertisement -