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)
 INSERT won't work...help!

Author  Topic 

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-06-23 : 11:49:53
Can anyone tell me why this won't work?

INSERT INTO tblNewCase ('#',CaseNumber,'#','1','#','0','#',FullName,'#','NULL','#',MailAddress,'#',MailCity,'#',MailState,'#',MailZipCode,'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#',PropAddress,'#',PropCity,'#',PropState,'#',PropZipCode,'#','#',MortAmount,'#',PaidUpFront,'#',HoldingMor,'#',ServingMor,'#',EndorseMonth+'/',EndorseDay+'/',EndorseYear,'#',Term,'#',MaturityMonth+'/',MaturityDay+'/',MaturityYear,'#',EncumMonth+'/',EncumDay+'/',EncumYear,'#',RefundAmount,'#','11','#','#','#','#','#')

SELECT CaseNumber,FullName,MailAddress,MailCity,MailState,MailZipCode,PropAddress,PropCity,PropState,PropZipCode,MortAmount,PaidUpFront,HoldingMor,ServingMor,EndorseMonth,EndorseDay,EndorseYear,Term,MaturityMonth,MaturityDay,MaturityYear,EncumMonth,EncumDay,EncumYear,RefundAmount
FROM tblHUDdata;

I know that looks like a bunch of junk, but I need all of that data. PLEASE HELP!

DavidRhodes
Starting Member

40 Posts

Posted - 2004-06-23 : 12:00:25
The number of columns doesn't match.
ie
you have
INSERT INTO tblNewCase ('#',CaseNumber,'#','1','#','0','#',FullName........
then
SELECT CaseNumber,FullName
Go to Top of Page

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-06-23 : 13:21:11
But I need to insert '#' into some columns. How can I insert those plus pull data from the other table? What is the best way to insert it? PLEASE HELP!
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-06-23 : 13:52:46
INSERT INTO myTable99(Col1,CaseNumber,Col3,COl4)
SELECT '#', CAseNumber, '#',Col4 FROM myOtherTable

The collist has to match the number of columns in the SELECT



Brett

8-)
Go to Top of Page
   

- Advertisement -