在我的tbl_AddImages上设置外键时出错 [英] Getting an error while set foreign key on my tbl_AddImages
问题描述
CREATE TABLE [dbo]。[tbl_AddItems](
[id] [int] IDENTITY(1,1)NOT NULL,
[ProductId] AS('SHPLT' +右('0000'+ CONVERT([varchar](10),[ID],(0)),(4)))PERSISTED NOT NULL,
CONSTRAINT PK_ProductId PRIMARY KEY CLUSTERED(ProductId),
[ProductCategory] [varchar](20)NULL,
[ProductName] [varchar](30)NULL,
[Price] [decimal](6,2)NULL,
[ProductCode ] [varchar](20)NULL,
[描述] [varchar](max)NULL,
[股票] [int] NULL,
[折扣] [int] NULL
)
创建 TABLE [dbo]。[tbl_AddImages]
(
[Id] INT IDENTITY ( 1 , 1 ) NOT NULL ,
[ProductId] VARCHAR (< span class =code-digit > 10 ) NOT NULL ,
[ImgId] [ varchar ]( 20 ) NULL ,
[ ImgPath] [ varchar ]( 100 ) NULL
CONSTRAINT [FK_ProductId] FOREIGN KEY ([ProductId]) REFERENCES [tbl_AddItems]([ProductId])
)
这里我想在我的桌子上设置主键和外键tbl_AddItems,tbl_AddImages
现在我得到了创建tbl_AddImages时出错
CREATE TABLE失败,因为以下SET选项的设置不正确:'ANSI_PADDING'。验证SET选项是否正确,可用于计算列和/或筛选索引和/或查询通知和/或XML数据类型方法和/或空间索引操作的索引视图和/或索引。
有人请帮我这个吗?
一般公式在这里
更改表ForeignKeyTable添加约束ForeignKeyTable_ForiegnKeyColumn_FK
FOREIGN KEY(ForiegnKeyColumn)引用PrimaryKeyTable(PrimaryKeyColumn)
查看此链接获取更多帮助
http://csharp-video-tutorials.blogspot.co.uk/2012/ 08 /创造和工作 - 表 - 部分3.html [ ^ ]
CREATE TABLE [dbo].[tbl_AddItems]( [id] [int] IDENTITY(1,1) NOT NULL, [ProductId] AS ('SHPLT'+right('0000'+CONVERT([varchar](10),[ID],(0)),(4)))PERSISTED NOT NULL, CONSTRAINT PK_ProductId PRIMARY KEY CLUSTERED(ProductId), [ProductCategory] [varchar](20) NULL, [ProductName] [varchar](30) NULL, [Price] [decimal](6, 2) NULL, [ProductCode] [varchar](20) NULL, [Descriptions] [varchar](max) NULL, [Stock] [int] NULL, [Discount] [int] NULL )
CREATE TABLE [dbo].[tbl_AddImages]
(
[Id] INT IDENTITY(1,1) NOT NULL,
[ProductId] VARCHAR(10) NOT NULL,
[ImgId] [varchar](20) NULL,
[ImgPath] [varchar](100) NULL
CONSTRAINT [FK_ProductId] FOREIGN KEY([ProductId]) REFERENCES [tbl_AddItems] ([ProductId])
)
Here i want to set primary key and foreign key on my tables tbl_AddItems,tbl_AddImages
now i'm getting an error at tbl_AddImages Creation
"CREATE TABLE failed because the following SET options have incorrect settings: 'ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations."
Anyone please help me regarding this?
The general formula is here
Alter table ForeignKeyTable add constraint ForeignKeyTable_ForiegnKeyColumn_FK
FOREIGN KEY (ForiegnKeyColumn) references PrimaryKeyTable (PrimaryKeyColumn)
see this link for more help
http://csharp-video-tutorials.blogspot.co.uk/2012/08/creating-and-working-with-tables-part-3.html[^]
这篇关于在我的tbl_AddImages上设置外键时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!