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
 Updating data from one table to another

Author  Topic 

gunsandbutter06
Starting Member

4 Posts

Posted - 2006-04-19 : 11:27:04
I am relatively new to SQL and am having trouble with an update. I know I cannot use a join update and have to use subquery. I am not sure of the syntax on how to do this. Below is basically what I want to do, but cannot figure out how to do it with a subquery. Any help would be appreciated.

update revisedapps
set alternateapp = t.alternateapp
from tempalternateapps t
join revisedapps r on t.appname = r.softwarename

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-19 : 11:30:39
I assume u r using SQL server:


update revisedapps set alternateapp = t.alternateapp
from revisedapps r
inner join tempalternateapps t on t.appname = r.softwarename


Srinika
Go to Top of Page

gunsandbutter06
Starting Member

4 Posts

Posted - 2006-04-19 : 11:47:58
Yes, I am using SQL Server 2000. When I run the code I get the error:

Server: Msg 8152, Level 16, State 6, Line 1
String or binary data would be truncated.
The statement has been terminated.
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-19 : 12:03:30
The Column alternateapp My not be large enough to hold data in t.alternateapp

First u may need to change the Column Size of both tables to be the larger of the 2 tbls.
Or u have to truncate data.

Find the field type / size of each of the above columns

Srinika
Go to Top of Page
   

- Advertisement -