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
 SQL Server Development (2000)
 won't insert...help!

Author  Topic 

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-08-09 : 15:18:14
This is my coding so far:

SELECT MailAddress,PropAddress,
(CASE WHEN MailAddress IS NULL THEN PropAddress ELSE MailAddress END)
FROM tblCapRec

It is not inserting into the table though. It displays it into a new "made-up" column, but it doesn't replace the NULL with a mailing address. Any ideas?

Thanks!

Brenda

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-09 : 15:22:21
Ok...

This will show you what you're going to change:
Select newMailAddress = isnull(MailAddress,PropAddress), oldMailAddress = MailAddress, PropAddress From tblCapRec

This will change it:
for update:
Update tblCapRec
Set MailAddress = isnull(MailAddress,PropAddress)
From tblCapRec

for insert into new table:
Insert Into YourNewTableName
Select MailAddress = isnull(MailAddress,PropAddress), PropAddress
From tblCapRec



Does that get it?


Corey
Go to Top of Page

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-08-09 : 15:37:05
I need to do something like this, but it won't work:

Update tblCapRec
Set MailAddress = ISNULL(MailAddress,PropAddress)
Set MailCity = ISNULL(MailCity,PropCity)
Set MailState = ISNULL(MailState,PropState)
Set MailZipCode = ISNULL(MailZipCode,PropZipCode)
From tblCapRec

What do I need to change?

Brenda
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-09 : 15:38:05
put commas in:

Update tblCapRec
Set
MailAddress = ISNULL(MailAddress,PropAddress),
MailCity = ISNULL(MailCity,PropCity),
MailState = ISNULL(MailState,PropState),
MailZipCode = ISNULL(MailZipCode,PropZipCode)
From tblCapRec

Corey
Go to Top of Page

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-08-09 : 15:43:08
Works perfect! Thanks Corey!
Go to Top of Page
   

- Advertisement -