Partial SQL Data copied from one table to another

I have a table with a ton of fields and I need to pull out a select few and insert the data into another existing table.

Specifically:

Location
-------
field1
field2
field3
Client
ContractAmt
ContractDate
field7
field8

Contracts
--------
ContractType (this is going to be 21 for all records
Client (set to Client from Table1)
ContractStartDate (needs to be set to ContractDate -1 year)
ExpireDate (set to ContractDate from Table1)
ContractAmt (set to ContractAmt from Table1)


Tried this:
INSERT INTO Contracts (ContractType, Client, ContractStartDate, ExpireDate, ContractAmt) VALUES (SELECT 21, Client, DATEADD('yy', -1, ContractDate), ContractDate, ContractAmt FROM Location)

but I get
Msg 1023, Level 15, State 1, Line 2
Invalid parameter 1 specified for dateadd.
LVL 97
Lee W, MVPTechnology and Business Process AdvisorAsked:
Who is Participating?
 
Pratima PharandeConnect With a Mentor Commented:
INSERT INTO Contracts
(ContractType, Client, ContractStartDate, ExpireDate, ContractAmt)
SELECT 21, Client, DATEADD(year, -1, ContractDate), ContractDate, ContractAmt FROM Location
0
 
Pratima PharandeCommented:
try

INSERT INTO Contracts
(ContractType, Client, ContractStartDate, ExpireDate, ContractAmt)
SELECT 21, Client, DATEADD('yy', -1, ContractDate), ContractDate, ContractAmt FROM Location
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Nope,
Msg 1023, Level 15, State 1, Line 4
Invalid parameter 1 specified for dateadd.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for pratima_mcs's comment #a39977381

for the following reason:

Thanks, that did the trick!
0
 
Pratima PharandeCommented:
it helps you right? then why 0 points ?
0
 
Pratima PharandeCommented:
thats fine. I just want to understand whether he needs more help in that.
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Sorry - that was a screwup on my part - your assistance was greatly appreciated (It was a late project for me so probably didn't have my head on straight...)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.