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.
Author |
Topic |
MariaM
Starting Member
17 Posts |
Posted - 2008-02-06 : 03:07:46
|
Hi all !I want to update one table with the contents of another table (which has the same variables). I do want to change the content of one of the variables at the same time though. Where this variable has the value of " " I want it to be null instead. Is it possible to do this in one statement ?/M |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-06 : 03:27:42
|
UPDATE t1SET t1.Col1 = NULLIF(t2.Col2, '') + '_Old'FROM Table1 AS t1INNER JOIN Table2 AS t2 ON t2.ColX = t1.ColBlue E 12°55'05.25"N 56°04'39.16" |
 |
|
MariaM
Starting Member
17 Posts |
Posted - 2008-02-06 : 04:19:52
|
Hi !Thanks for the help. I didn't understand all of the query though. Do you think you could explain a little more ?/M |
 |
|
MariaM
Starting Member
17 Posts |
Posted - 2008-02-06 : 04:25:32
|
Hi again !I'm sorry , but I think I explained wrong what I want to do. I want to insert into a table not update. /M |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-06 : 04:27:56
|
INSERT INTO DestinationTable (field1,Field2,...)SELECT Field1,NULLIF(Field2,''),....other fieldsFROM SourceTableField2 is the one you need to replace '' by NULL |
 |
|
|
|
|