What's wrong with this insert statement?

I keep getting this error:
The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.

Table1 that i'm inserting into has 17 columns. Table2 that i'm reading from has 3 columns.
I keep counting and the insert and select parameters match,,,
what am I missing?
Insert into dbo.Table1  (ID,
                                   CreatedOn,
                                   UpdatedOn,
                                   ModifiedBy,
                                   RowVersion,
                                   LocaleID,
                                   ProcessorId,
                                   IsActive,
                                   Code,
								   Description,
                                   FromName,
                                   FromEmailAddress,
                                   ToName,
                                   ToEmailAddress,
                                   Subject,
                                   TextBody,
                                   HtmlBody)
select NewID(),
       getdate(),
       getdate(),
       null,
       (select @@DBTS) as RowVersion,
       1031,
       id,
       0,
       'Ship',
       'Sent email.',
       'Customer service,
       'test@test.com',
       '{Customer.FirstName} {Customer.LastName}',
       '{Customer.EmailAddress}',
       'Ship Confirmation for Order #{Number}',
       'Text Body ship - text goes here'
       'HTML Body ship - text goes here'
 
  from Table2
where [name] = 'XY123'

Open in new window

LVL 8
CamilliaAsked:
Who is Participating?
 
tigin44Commented:
as I see you have forgetten to put a ',' ofter the
'Text Body ship - text goes here'
line
0
 
tigin44Commented:
can
'Text Body ship - text goes here'
'HTML Body ship - text goes here'
fields can contain single quotation mark...
0
 
brad2575Commented:
change this:

select NewID(),
       getdate(),
       getdate(),
       null,
       (select @@DBTS) as RowVersion,
       1031,
       id,
       0,
       'Ship',
       'Sent email.',
       'Customer service,
       'test@test.com',
       '{Customer.FirstName} {Customer.LastName}',
       '{Customer.EmailAddress}',
       'Ship Confirmation for Order #{Number}',
       'Text Body ship - text goes here'
       'HTML Body ship - text goes here'


to this:

select NewID(),
       getdate(),
       getdate(),
       null,
       (select @@DBTS) as RowVersion,
       1031,
       id,
       0,
       'Ship',
       'Sent email.',
       'Customer service,
       'test@test.com',
      Customer.FirstName + ' ' + Customer.LastName,
       'Customer.EmailAddress',
       'Ship Confirmation for Order #' + Number,
       'Text Body ship - text goes here'
       'HTML Body ship - text goes here'
0
 
CamilliaAuthor Commented:
tigin44, just noticed the missing comma, let me try
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.