SQL SERVER 2005问题!急!

ll1988228 2010-01-18 10:39:23
各位大侠们:
你们好,我用POWERDESIGNER12.0 生成SQL语句后到SQL SERVER2005中执行,提示出错误:
消息 156,级别 15,状态 1,第 7 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 9 行
关键字 'delete' 附近有语法错误。
消息 156,级别 15,状态 1,第 12 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 14 行
关键字 'delete' 附近有语法错误。
消息 156,级别 15,状态 1,第 22 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 24 行
关键字 'if' 附近有语法错误。
消息 156,级别 15,状态 1,第 31 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 33 行
关键字 'if' 附近有语法错误。
消息 156,级别 15,状态 1,第 40 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 42 行
关键字 'if' 附近有语法错误。
消息 156,级别 15,状态 1,第 49 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 51 行
关键字 'if' 附近有语法错误。
消息 156,级别 15,状态 1,第 58 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 60 行
关键字 'if' 附近有语法错误。
消息 156,级别 15,状态 1,第 66 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 68 行
关键字 'if' 附近有语法错误。
消息 156,级别 15,状态 1,第 74 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 76 行
关键字 'if' 附近有语法错误。
消息 156,级别 15,状态 1,第 82 行
关键字 'then' 附近有语法错误。
消息 156,级别 15,状态 1,第 84 行
关键字 'if' 附近有语法错误。
消息 102,级别 15,状态 1,第 94 行
'varchar' 附近有语法错误。
SQL语句是:
/*==============================================================*/
/* DBMS name: Sybase AS Anywhere 9 */
/* Created on: 2010-1-18 9:47:06 */
/*==============================================================*/


if exists(select 1 from sys.sysforeignkey where role='FK_TOTAL_RELATIONS_CUSTOMER') then
alter table total
delete foreign key FK_TOTAL_RELATIONS_CUSTOMER
end if;

if exists(select 1 from sys.sysforeignkey where role='FK_TOTAL_RELATIONS_COMMODIT') then
alter table total
delete foreign key FK_TOTAL_RELATIONS_COMMODIT
end if;

if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='commodity_PK'
and t.table_name='commodity'
) then
drop index commodity.commodity_PK
end if;

if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='customer_PK'
and t.table_name='customer'
) then
drop index customer.customer_PK
end if;

if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_1_FK'
and t.table_name='total'
) then
drop index total.Relationship_1_FK
end if;

if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_2_FK'
and t.table_name='total'
) then
drop index total.Relationship_2_FK
end if;

if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='total_PK'
and t.table_name='total'
) then
drop index total.total_PK
end if;

if exists(
select 1 from sys.systable
where table_name='commodity'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table commodity
end if;

if exists(
select 1 from sys.systable
where table_name='customer'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table customer
end if;

if exists(
select 1 from sys.systable
where table_name='total'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table total
end if;

/*==============================================================*/
/* Table: commodity */
/*==============================================================*/
create table commodity
(
comm_num varchar(10) not null,
comm_name varchar(11),
comm_price integer,
comm_intro long varchar,
constraint PK_COMMODITY primary key (comm_num)
);

/*==============================================================*/
/* Index: commodity_PK */
/*==============================================================*/
create unique index commodity_PK on commodity (
comm_num ASC
);

/*==============================================================*/
/* Table: customer */
/*==============================================================*/
create table customer
(
cus_num varchar(10) not null,
cus_name varchar(20),
cus_phone varchar(11),
cus_address varchar(50),
cus_email varchar(15),
constraint PK_CUSTOMER primary key (cus_num)
);

/*==============================================================*/
/* Index: customer_PK */
/*==============================================================*/
create unique index customer_PK on customer (
cus_num ASC
);

/*==============================================================*/
/* Table: total */
/*==============================================================*/
create table total
(
cus_num varchar(10) not null,
comm_num varchar(10) not null,
total_price integer,
total_number integer,
constraint PK_TOTAL primary key clustered (cus_num, comm_num)
);

/*==============================================================*/
/* Index: total_PK */
/*==============================================================*/
create unique index total_PK on total (
cus_num ASC,
comm_num ASC
);

/*==============================================================*/
/* Index: Relationship_1_FK */
/*==============================================================*/
create index Relationship_1_FK on total (
cus_num ASC
);

/*==============================================================*/
/* Index: Relationship_2_FK */
/*==============================================================*/
create index Relationship_2_FK on total (
comm_num ASC
);

alter table total
add constraint FK_TOTAL_RELATIONS_CUSTOMER foreign key (cus_num)
references customer (cus_num)
on update cascade
on delete cascade;

alter table total
add constraint FK_TOTAL_RELATIONS_COMMODIT foreign key (comm_num)
references commodity (comm_num)
on update cascade
on delete cascade;


请你们帮我解决下啊!
...全文
152 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Johnson_Hong 2010-01-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 johnson_hong 的回复:]
很明显你生成的语句是orcle的,需要选择数据库类型为sql-server
[/Quote]
sysbase AS Anywhere 当然不是oracle

刚才没注意看,只看了一个varchar,就判断是oracle了,后来看了一下
DBMS name: Sybase AS Anywhere 9
那你的数据库就是Sybase AS Anywhere 9
阿_布 2010-01-18
  • 打赏
  • 举报
回复
sys.sysforeignkey oracle里面的
ll1988228 2010-01-18
  • 打赏
  • 举报
回复
那么请问仁兄,怎么看出来是ORCLE的?
SambaGao 2010-01-18
  • 打赏
  • 举报
回复
Sybase是一个数据库
数据库有
Sybase mysql oracle sqlserver db2
ll1988228 2010-01-18
  • 打赏
  • 举报
回复
非常感谢!哈哈,我是刚刚学习的菜鸟,还想请教你个问题就是Sybase AS Anywhere 9 就是值得ORCLE么?
xuexijava 2010-01-18
  • 打赏
  • 举报
回复
mark
SambaGao 2010-01-18
  • 打赏
  • 举报
回复
楼上兄台怎么看出来是oracle的?
Johnson_Hong 2010-01-18
  • 打赏
  • 举报
回复
先到database-->change current database下切换当前数据库为sql-server2000,然后再生成就ok了
Johnson_Hong 2010-01-18
  • 打赏
  • 举报
回复
很明显你生成的语句是orcle的,需要选择数据库类型为sql-server
码农小小鸟 2010-01-18
  • 打赏
  • 举报
回复
在生成Sql语你设置一下生成sql语句的格式就可以了,在databasegeneration-----option中把检查语句去了,还有一种方法,你直接连上数据库后,直接在数据库里面生成.
qianmz 2010-01-18
  • 打赏
  • 举报
回复
SQLServer varchar
Oracle varchar2

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧