sql语句里面能写if 语句吗???? 不是存储过程,也不是触发器

如题所述

第1个回答  2011-08-13
可以,比如创建表的时候,例如
if exists (select * from sysobjects where id = object_id(N'table_name'))
drop table table_name
GO
CREATE TABLE table_name(....)
GO
表 table_name 若存在则删除重建一个新的 table_name
第2个回答  2011-08-13
可以,不过是用 case when来表示
第3个回答  2011-08-13
可以用case when 替代
if a>100 then
...
else
...
end
可以改为
case when a>100 then ... else ... end本回答被提问者采纳
第4个回答  2011-08-13
t-sql里面是可以的
相似回答