Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DHale
Starting Member
4 Posts |
Posted - 2008-10-21 : 13:31:39
|
Hi my name is Diane I am a student in SQL I tring to writh an Chart of Account I get this error(Msg 213, Level 16, State 1, Line 2Insert Error: Column name or number of supplied values does not match table definition.Msg 213, Level 16, State 1, Line 5Insert Error: Column name or number of supplied values does not match table definition.Msg 213, Level 16, State 1, Line 8Insert Error: Column name or number of supplied values does not match table definition.Msg 213, Level 16, State 1, Line 11Insert Error: Column name or number of supplied values does not match table definition.Msg 213, Level 16, State 1, Line 14Insert Error: Column name or number of supplied values does not match table definition.Msg 213, Level 16, State 1, Line 17)Would someone please point me in the right direct Thank you code listed below.if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[COA]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[COA]GOCREATE TABLE COA( coa_id int identity (1, 1) not null, parent_id int not null default 0, account_name varchar (100) not null, amt money default 0, primary key(coa_id))GOINSERT INTO COA VALUES('CHART OF ACCOUNT');INSERT INTO COA VALUES('PETTY CASH');INSERT INTO COA VALUES('Workers Compensation');INSERT INTO COA VALUES('Accounts Receivable');INSERT INTO COA VALUES('Reserve for Bad Debts');INSERT INTO COA VALUES('Reserve for Bad Debts');Select * from coaselect * from coa where account_name = P |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-10-21 : 13:39:52
|
INSERT INTO COA (account_name) VALUES ('CHART OF ACCOUNT');EtcYou have to list the columns you are inserting.The others are ok because they have a default value."God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
|
|
DHale
Starting Member
4 Posts |
Posted - 2008-10-21 : 14:10:27
|
I am feeling a little braindead right about now is this correct place to insert the line.Msg 4145, Level 15, State 1, Line 20An expression of non-boolean type specified in a context where a condition is expected, near 'account_name'.f exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[COA]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[COA]GOCREATE TABLE COA( coa_id int identity (1, 1) not null, parent_id int not null default 0, account_name varchar (100) not null, amt money default 0, primary key(coa_id))GOINSERT INTO COA (account_name) VALUES ('CHART OF ACCOUNT');INSERT INTO COA VALUES('PETTY CASH');INSERT INTO COA VALUES('Workers Compensation');INSERT INTO COA VALUES('Accounts Receivable');INSERT INTO COA VALUES('Reserve for Bad Debts');INSERT INTO COA VALUES('Reserve for Bad Debts');Select * from coaselect * from coa where account_name |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-10-21 : 14:15:07
|
[code]if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[COA]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[COA]GOCREATE TABLE COA(coa_id int identity (1, 1) not null,parent_id int not null default 0,account_name varchar (100) not null,amt money default 0,primary key(coa_id))GOINSERT INTO COA (account_name) VALUES ('CHART OF ACCOUNT');INSERT INTO COA (account_name) VALUES ('PETTY CASH');INSERT INTO COA (account_name) VALUES ('Workers Compensation');INSERT INTO COA (account_name) VALUES ('Accounts Receivable');INSERT INTO COA (account_name) VALUES ('Reserve for Bad Debts');INSERT INTO COA (account_name) VALUES ('Reserve for Bad Debts');Select * from coaselect * from coa where account_name='P' --NOTE This will NOT return anythingselect * from coa where account_name Like 'P%' --This will[/code]"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
|
|
DHale
Starting Member
4 Posts |
Posted - 2008-10-21 : 15:34:26
|
I under stand thank you. |
|
|
|
|
|
|
|