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
 What the ***** am i missing

Author  Topic 

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-30 : 10:01:28
I swear, i've done this before, but my alzheimers is kicking in again. I have two tables. Table A and Table B Table A has all the columns that Table B has, and then some. I need to insert the data from the columns in Table A which match the columns in Table B, while ignoring the columns that do not match. Why is the following not working????:


INSERT INTO civil.dbo.receipts
SELECT ([RECEIPTNO]
,[AGENCYNO]
,[RECEIVEDATE]
,[RECEIVETIME]
,[CLERK]
,[CATEGORY]
,[TYPEWRIT]
,[STATUS]
,[STATUSDATE]
,[PLAINTIFF]
,[DEFENDANT]
,[THIRDPARTY]
,[CLERKOFCOURT]
,[COURTNAME]
,[CASENO]
,[DORCASENO]
,[COUNTY]
,[COURTDATE]
,[APPEARBEFORE]
,[SERVEBY]
,[SERVICECOST]
,[OTHERFEES]
,[FEETYPE]
,[DEPOSITAMOUNT]
,[DEPOSITRECEIPT]
,[PAYMENTTYPE]
,[CHECKNO]
,[DEPOSITDATE]
,[REFUNDDATE]
,[REFUND]
,[REFUNDCHECKNO]
,[REFUNDRECEIPT]
,[ATTORNEYID]
,[WKSHTOPTION]
,[EXCLUSIVE]
,[FIREUSE]
,[FIRESURR]
,[FIREARMSTO]
,[CUSTODY]
,[CHILDRENTO]
,[COMMENTS]
,[PRINTCOMMENTS]
,[UNIQUEKEY]
,[ProcessTypeFKey]
,[ISSUEDATE]) FROM GCSOCIVILCONVERSION.dbo.GCSOreceipts s


Even removing the parens from the select has no effect.

driving me nuts

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-30 : 10:04:01
You need a Column list civil.dbo.receiptscivil.dbo.receipts

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-30 : 10:04:29
I gave you code to generate this code. Are you not using it?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-30 : 10:04:32
What is the error message?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-30 : 10:07:33
Brett: couldn't find it. fred: "Incorrect syntax near ",""
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-30 : 10:10:45
remove the parentheses


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-30 : 10:11:44
did. same result
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-30 : 10:14:04
Ugh. Ok this really irritates me. the query window continued to show syntax errors all over the statement, but, upon executing without the parens (despite the errors still being highlighted in the parsed query), the query executed.

No explanation. Been toying with this for over an hour.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-30 : 10:18:50
Don't believe in the highlighted bullshit.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-03-30 : 10:24:17
Edit->Intellisense->refresh local cache

--
Gail Shaw
SQL Server MVP
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-30 : 10:53:56
thank you!
Go to Top of Page
   

- Advertisement -