Click here to Skip to main content
15,899,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've got the following code:

SQL
INSERT INTO [ALFA].[dbo].[tblSalesOrders]
 ([strSalesOrderNo], [SalesOrderNo], [LineNo], [OrderedItem], [SO_Quantity], 
 [SO_SellingPrice], [SO_SellingValue], [PONumber], [PO_UnitPrice], [PO_CostValue], 
 [PO_ReceiptDate]) 

  VALUES
  ('21700' ,21,700.00 ,1.00 ,'ADE-8002' ,1.00 ,143.79 ,143.79 ,28623 ,108.79 ,108.79
   ,Convert(DateTime,15/01/2013   1:39:36PM,103))


and I keep getting the following 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.

Does anyone know where I'm going wrong?

Thanks
Posted
Comments
Mike Meinz 26-Jun-13 11:07am    
It looks like [strSalesOrderNo], should be removed from your INSERT statement.

You've only defined 11 column names, but you've defined 12 values to be inserted. You need one column name.

The problem is this:
21,700.00

You can't use "," as thousands separator. You need to write 21700.00
 
Share this answer
 
v4
Comments
Maciej Los 26-Jun-13 13:20pm    
+5See my answer ;)
Yes.
[strSalesOrderNo],   '21700' ,                                       
[SalesOrderNo],       21,                                             
[LineNo],             700.00 ,                                        
[OrderedItem],        1.00 ,                                          
[SO_Quantity],        'ADE-8002' ,                                    
[SO_SellingPrice],    1.00 ,                                          
[SO_SellingValue],    143.79 ,                                        
[PONumber],           143.79 ,                                        
[PO_UnitPrice],       28623 ,                                         
[PO_CostValue],       108.79 ,                                        
[PO_ReceiptDate])     108.79 ,                                        
                      Convert(DateTime,15/01/2013   1:39:36PM,103))   
Probably, you want to dump the comma indicating thousands in the second value!
 
Share this answer
 
Comments
Maciej Los 26-Jun-13 13:20pm    
+5See my answer ;)
Another issue is that the date and time value is without (') sign:
SQL
Convert(DateTime,15/01/2013   1:39:36PM,103))

It should be:
SQL
Convert(DateTime,'15/01/2013   1:39:36PM',103))
 
Share this answer
 
v2
Comments
WajihaAhmed 26-Jun-13 12:07pm    
One thing I really like about code project is, even if the problem is very trivial, you guys care to help. Simply awesome !
Maciej Los 26-Jun-13 13:20pm    
In community behalf, thank you ;)

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