Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The number of columns for each row in a table value constructor must be the same.?

5,692 views
Skip to first unread message

Andy B.

unread,
Mar 24, 2010, 9:46:57 AM3/24/10
to
I have the following script that inserts rows into the table type and sends
the table to the DeleteHeadlines stored procedure.

1. The rows listed below that are inserted into the parameter already exist
in the table itself.

2. The stored procedure uses a merge to delete all of the rows if they exist
in the source/target.

3. I get the following error on line 11: "The number of columns for each row
in a table value constructor must be the same."

4. In order, the tables columns are
HeadlineID,HeadlineTitle,HeadlineDescription,HeadlineContent,HeadlineStartDate,HeadlineEndDate,HeadlineLastUpdated.

I can't figure out why I keep getting this error when I had done the exact
same thing to test my insert with merge. Any ideas?

declare @Headlines as [Headlines].[HeadlinesTable]

insert into @Headlines
(HeadlineID,HeadlineTitle,HeadlineDescription,HeadlineContent,HeadlineStartDate,HeadlineEndDate,HeadlineLastUpdated)

values

(10,'rollback','Testing transactions that should work.','What is there to
say about inserts?','2010-03-12','2012-05-31',null),

(15,'rollback1','Testing transactions that should work. What is there to say
about inserts?','2010-03-12','2012-05-31',NULL),

(18,'rollback2','Testing transactions that should work. What is there to say
about inserts?','2010-03-12','2012-05-31',NULL),

(28,'rollback3','Testing insert','Who
knows?','2010-03-03','2010-11-05',NULL),

(30,'rollback4','Testing insert','Who
knows?','2010-03-03','2010-11-05',NULL)

go

exec [Headlines].[DeleteHeadlines] @Headlines


Mark Fitzgerald

unread,
Mar 24, 2010, 10:12:08 AM3/24/10
to
The first 2 insert statements do not have the same structure. Below are the
lines expanded to a column per row. Note that the string content is split
into two lines in the first insert but only one in the second. Typo
probably.

(10,
'rollback',
'Testing transactions that should work.',
'What is there to say about inserts?',
'2010-03-12',
'2012-05-31',
null),

(15,
'rollback1',
'Testing transactions that should work. What is there to say about
inserts?',
'2010-03-12',
'2012-05-31',
NULL),

Fitz

"Andy B." <a_b...@sbcglobal.net> wrote in message
news:OoD0zh1y...@TK2MSFTNGP05.phx.gbl...

0 new messages