运行脚本时出现SQL错误

运行脚本时出现SQL错误

本文介绍了运行脚本时出现SQL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过运行此脚本,我正在得知RACE_ID不存在错误,请让我知道这有什么问题...
注意:数据库中存在一个不包含Race_ID列的"Easternity_Master"表

Im Getting That RACE_ID does''nt Exist Error by running this script please let me know whats wrong in this...
Note: There is a table Ethnicity_Master without the Race_ID column exists in the Database

if exists(select * from Sysobjects
where Xtype=''U'' and ltrim(rtrim(Name))=''Ethnicity_Master'')
begin
drop table Ethnicity_Master
CREATE TABLE Ethnicity_Master
(
Ethnicity_ID int primary key identity (1,1) not null,
Race_ID  int ,
Ethnicity_Description nvarchar(500),
foreign key (Race_ID) references Race_Master(Race_ID) on delete cascade
)
end
else
Begin
CREATE TABLE Ethnicity_Master
(
Ethnicity_ID int primary key identity (1,1) not null,
Race_ID  int ,
Ethnicity_Description nvarchar(500),
foreign key (Race_ID) references Race_Master(Race_ID) on delete cascade
)
End
insert into Ethnicity_Master(Race_ID,Ethnicity_Description) values(1,''European'')
insert into Ethnicity_Master(Race_ID,Ethnicity_Description) values(1,''Armenian'')
insert into Ethnicity_Master(Race_ID,Ethnicity_Description) values(1,''English'')

推荐答案


这篇关于运行脚本时出现SQL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 21:57