|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
错误信息:
-2147217900
在被引用表 'code' 中没有与外键 'FK__Ap_InvCod__cInpC__006AEB82' 中的引用列列表匹配的主键或候选键。
执行如下语句时出错:
declare @tn nvarchar(100)
set @tn=N'T_'+replace(newid(),'-','_')
if exists (select * from dbo.sysobjects where id = object_id(N'[Ap_InvCode]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
begin
exec('Select iTag,cKeyCode,cInpCode1,cInpCode2,cInpCode3,cFlag into '+@tn+' from Ap_InvCode')
drop table [Ap_InvCode]
end
CREATE TABLE [Ap_InvCode] (
[Auto_ID] [int] IDENTITY (1, 1) NOT NULL ,
[iTag] [tinyint] NOT NULL ,
[cKeyCode] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[cInpCode1] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
[cInpCode2] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
[cInpCode3] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
[cFlag] [nvarchar] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[iTax] [money],
CONSTRAINT [aaaaaAp_InvCode_PK] PRIMARY KEY NONCLUSTERED
(
[cFlag],
[iTag],
[cKeyCode],
[iTax]
) ON [PRIMARY] ,
CONSTRAINT [FK__Ap_InvCod__cInpC__006AEB82] FOREIGN KEY
(
[cInpCode2]
) REFERENCES [code] (
[ccode]
),
CONSTRAINT [FK__Ap_InvCod__cInpC__015F0FBB] FOREIGN KEY
(
[cInpCode3]
) REFERENCES [code] (
[ccode]
),
CONSTRAINT [FK__Ap_InvCod__cInpC__025333F4] FOREIGN KEY
(
[cInpCode1]
) REFERENCES [code] (
[ccode]
)
) ON [PRIMARY]
if exists (select * from dbo.sysobjects where id = object_id(@tn) and OBJECTPROPERTY(id, N'IsUserTable') = 1)
begin
exec('insert into Ap_InvCode(iTag,cKeyCode,cInpCode1,cInpCode2,cInpCode3,cFlag,iTax)Select iTag,cKeyCode,cInpCode1,cInpCode2,cInpCode3,cFlag,-1 as iTax From '+@tn)
exec('drop table '+@tn)
end
|
|