Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to insert a value for this table


ID -> (PK,FK,int,notnull)
DNumber -> (nvarchar(15),notnull)
LoginID -> (nvarchar(256),notnull)
OrgNode -> (hierarchyid,null)
OrgLevel -> (computed,smallint,null)
JobTitle -> (nvarchar(50),notnull)
BirthDate -> (date, notnull)
MaritalStatus -> (nchar(1),notnull)
Gender -> (nchar(1),notnull)
HireDate -> (date, notnull)
SalariedFlag -> (Flag(bit),notnull)
VacationHours -> (smallint,not null)
SickLeaveHours -> (smallint,not null)
CurrentFlag -> (Flag(bit),notnull)
rowguid -> (uniqueidentifier, notnull)
ModifiedDate -> (datetime,notnull)
Posted
Comments
Tomas Takac 19-Jun-15 5:51am    
Using the INSERT statement of course. What's the problem here?
Deepak Ratan 19-Jun-15 6:10am    
I am Geeting ERROR: "There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement."


INSERT INTO Employee (DNumber,LoginID,OrgNode,OrgLevel,JobTitle,BirthDate,MaritalStatus,Gender,HireDate,
SalaiedFlag,VacationHours,SickLeaveHours,CurrentFlag,rowguid ,ModifiedDate)
Values('295847284','adventure-works\ken0','0x',0,'Java','1963-03-02','S','M',
'2003-02-15',1,99,69,1,'F01251E5-96A3-448D-981E-0F99D789110D','2008-07-31')
DamithSL 19-Jun-15 5:52am    
what have you tried so far?
Deepak Ratan 19-Jun-15 6:10am    
I am Geeting ERROR: "There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement."


INSERT INTO Employee (DNumber,LoginID,OrgNode,OrgLevel,JobTitle,BirthDate,MaritalStatus,Gender,HireDate,
SalaiedFlag,VacationHours,SickLeaveHours,CurrentFlag,rowguid ,ModifiedDate)
Values('295847284','adventure-works\ken0','0x',0,'Java','1963-03-02','S','M',
'2003-02-15',1,99,69,1,'F01251E5-96A3-448D-981E-0F99D789110D','2008-07-31')

1 solution

Hi, you have to insert into database by using "Insert into" query,

Try this,

SQL
INSERT INTO yourtableName (DNumber,LoginID,OrgNode,OrgLevel,JobTitle,BirthDate,MaritalStatus,Gender,HireDate,
SalaiedFlag,VacationHours,SickLeaveHours,CurrentFlag,rowguid ,ModifiedDate)
Values(@DNumber,@LoginID,@OrgNode,@OrgLevel,@JobTitle,@BirthDate,@MaritalStatus,@Gender,
@HireDate,@SalariedFlag,@VacationHours,@SickLeaveHours,@CurrentFlag,@rowguid ,@ModifiedDate)

where the values having prefix '@' contains the actual data which you have to insert



Thanks in advance
 
Share this answer
 
Comments
Deepak Ratan 19-Jun-15 6:07am    
I am Geeting ERROR: "There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement."


INSERT INTO Employee (DNumber,LoginID,OrgNode,OrgLevel,JobTitle,BirthDate,MaritalStatus,Gender,HireDate,
SalaiedFlag,VacationHours,SickLeaveHours,CurrentFlag,rowguid ,ModifiedDate)
Values('295847284','adventure-works\ken0','0x',0,'Java','1963-03-02','S','M',
'2003-02-15',1,99,69,1,'F01251E5-96A3-448D-981E-0F99D789110D','2008-07-31')
jaket-cp 19-Jun-15 6:21am    
Is your ID field an identity column?
If it is not, then add the ID into to SQL statement also.
Deepak Ratan 19-Jun-15 6:25am    
If I am adding ID Column then also its showing ERROR
jaket-cp 19-Jun-15 6:27am    
make sure you have the same amount of values as you do columns specified
Deepak Ratan 19-Jun-15 6:25am    
ERROR:
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900