插入语句错误 [英] Insert Statement Error

查看:125
本文介绍了插入语句错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:



  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
转换 DateTime ,15/01/2013 1:39:36 PM, 103 ))





我一直收到以下错误



INSERT语句中的列少于VALUES子句中指定的值。 VALUES子句中的值的数量必须与INSERT语句中指定的列数相匹配。



有谁知道我哪里出错了?



谢谢

解决方案

您只定义了11个列名,但是您已经定义了12个值插入。你需要一个列名。



问题是:

21,700.00



您不能使用,作为千位分隔符。你需要写21700.00


是。

 [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,
转换(DateTime,15/01/2013 1:39:36 PM,103))

可能你想要转储逗号,表示第二个值为数千!


另一个问题是日期和时间值没有(')签名:

 转换 DateTime ,15/01/2013 1:39:36 PM, 103 ))



它应该是:

 转换 DateTime ,< span class =code-string>'  15/01/2013 1:39:36 PM' 103 ))


I've got the following code:

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

解决方案

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


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!


Another issue is that the date and time value is without (') sign:

Convert(DateTime,15/01/2013   1:39:36PM,103))


It should be:

Convert(DateTime,'15/01/2013   1:39:36PM',103))


这篇关于插入语句错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆