English 中文(简体)
服务器—— 213女士—— 插入“错误”: 所提供的数值的颜色或数与表格定义不符
原标题:SQL server - Msg 213 - Insert Error: Column name or number of supplied values does not match table definition
  • 时间:2010-08-21 20:36:01
  •  标签:
  • sql-server

在服务器中,我试图通过使用以下格言将数值从一个桌上加到另一个桌上:

delete from tblTable1

insert into tblTable1 select * from tblTable1_Link

我正在犯以下错误:

Column name or number of supplied values does not match table definition.

我确信,这两个表的结构、栏目和数据类型相同。

感谢您的帮助。 我已尝试将此张贴到,但我没有回答,尽管我会在这里尝试更多的活动。

问题回答

该栏中是否有一栏是身份识别栏?

SET IDENTITY_INSERT tblTable1 ON
insert into tblTable1 select * from tblTable1_Link
SET IDENTITY_INSERT tblTable1 OFF

请你在您的数据库中作这一发言,并给我们这一产出?

SELECT 
    c.name,
    c.is_identity,
    c.is_computed, 
    t.name  Type name 
FROM sys.columns c
INNER JOIN sys.types t ON c.user_type_id = t.user_type_id
WHERE object_id = object_ID( tblTable1 )

问题:

  • is there any column that has is_identity set to 1 (true) ?
  • is there any column that has is_computed set to 1 (true) ?
  • is there any column with a type of timestamp or rowversion ??

如果你有任何一栏:你不能轻易将其中的任何一栏列入<代码>。 INSERT statement. 您可以确定一些额外工作的身份栏,但计算栏目或类型栏目<代码>。 TIMESTAMP/ROWVERSIONcannot,在任何情况下都应制定。

因此,我建议<>途径明确列出栏目清单,即使你需要所有栏目:

INSERT INTO dbo.tblTable1(col1, col2, ...., colX)
   SELECT col1, col2, ...., colX FROM dbo.tblTable1_Link

采用这种办法,你可以排除不能轻易插入的任何一栏。

+1 for @fosco as that s mostrisk.

但有一点是,如果你只是拿走一个相互关联的表格,从而每次空出一张桌子,那么你就可以做这样的事情:

DROP TABLE tblTable1 -- assuming there are no FKs

select * INTO tblTable1 from tblTable1_Link
--  Then Re-create keys / indexes

这将意味着,如果图形1-链接改动,这种改动也将列入目的地表。





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签