sql 156错误

来源:百度知道 编辑:UC知道 时间:2024/05/06 04:09:58
create table girl
as select sno,sname,age
from students
where sex='女'
为什么会有156错误阿
服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'as' 附近有语法错误。
我是新手,现在正在学sql,希望大家帮帮小弟
我学的是《数据库原理与设计》(第二版)人民邮电出版社,在第53页例3.3中有上面的代码,我用的是MSSQL2000,如果要改,具体应如何改?
另外,书上说,代码是用SQL标准语言编的,我要是用MSSQL2000应该注意什么?

给出两种正确答案:
create table girl(sno int,sname varchar(20),age int)
insert into girl select * from students where sex='女'

select * into girl select sno,sname,age from students where sex='女'

不能吧?
应该是
create view girl
as select sno,sname,age
from students
where sex='女'

嗯 要是创建视图的话那就如一楼所说的
要是新建一个表的话要就是二楼的答案 不过二楼的第一种答案是对的第二个多出了一个select语句啊 写成select * into girl from students where sex='女' 或select sno,sname,age into girl from students where sex='女'
不过我也很迷惑啊 为什么不要先建一个girl表 直接用select into语句就能又建立girl表又能选出元组 ,,不太明白 懂的人顺便说一下啊

所以楼主上面的create table girl就不要了啊 直接用select into就行了!!!!

oracle,sybase都可以象你那样写,MSsql要象二楼WHITE_WIN