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)
 Replace row content with other row content question!

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-07-12 : 11:17:14
writes "I've got an SQL server question. I've got a table with 3 columns and 100 rows.

I want to write some SQL which will replace whatever is in column 3, with exactly what is in column 1, and then add '.jpg' at the end. Ideally I want this to do all 100 rows in one hit.

Any help would be great! thanks!

Paul"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-12 : 11:18:44
[code]update table
set col3 = col1 + '.jpg'
[/code]


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-13 : 01:27:45
Note that If col1 is null then col3 will also be null

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-07-13 : 02:05:55
add a where clause...

where col1 is not null

--------------------
keeping it simple...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-13 : 03:58:04
in summary

update table
set col3 = col1 + '.jpg'
where col1 is not null



KH

Go to Top of Page
   

- Advertisement -