June 19, 2017 at 12:12 pm
Hi all,
I am getting an error while running code below on MSSql 2008R2. What am I missing???
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'dbo.B') AND type in (N'U'))
Drop table B;
create table B (
acct_id int,
entity varchar(30),
first_name varchar(30),
last_name varchar(30),
email varchar(30),
created_date datetime not null default getdate()
)
insert into b values (1, 'a', 'e', 'p', 'ep@c.com')
Msg 213, Level 16, State 1, Line 1
Column name or number of supplied values does not match table definition.
June 19, 2017 at 12:22 pm
your table has 6 columns in it, but your INSERT statement only has 5 columns. If you don't specify a value for all 6 columns, you have to explicitly specify the columns like this:
insert into b
(acct_id, entity, first_name, last_name, email)
values
(1, 'a', 'e', 'p', 'ep@c.com')
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy