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.
(ContractType, Client, ContractStartDate, ExpireDate, ContractAmt)
SELECT 21, Client, DATEADD(year, -1, ContractDate), ContractDate, ContractAmt FROM Location