MSSQLServer和Sybase的一些区别!
好久没来了,死想你们了!
因工作需要使用sybase数据库,以前没碰过sybase,看了两天感觉好别扭(和MSSQLServer相比),暂整理出25点,也不知道对不对!
顺祝各位XDJM中秋、国庆快乐!
1.sybase没有用户自定义函数
2.判断fetch成功的全局变量是@@sqlstatus,不是@@fetch_status
3.没有set,赋值与查询通用select
4.没有top,返回N行要使用set rowcount N / set rowcount 0
5.raiserror 22009 ""-->raiserror('',16,1)
6.游标一定要在过程中使用,不能单独在查询中使用
7.销毁游标要加cursor关键字.如:deallocate cursor cur_tmp
8.没有bigint类型
9.create table #t(id numeric(12,0) identity not null),不支持int型,且不能设置起始值和步进值
10.不能alter一个存储过程,要先drop掉再create
11.没有len函数,使用char_length或datalength等效
12.通过sysindexes中的doampg列可返回某表的行数,rowcnt(doampg)
13.convert函数没有120格式(yyyy-mm-dd hh:mm:ss),需使用select convert(char(4),datepart(year,getdate()))+'-'+right('0'+convert(varchar(2),datepart(month,getdate())),2)+'-'+right('0'+convert(varchar(2),datepart(day,getdate())),2)+' '+convert(char(10),getdate(),8)
14.charindex不能从被查找字符串中按指定位置查找某字符串
15.不能使用rtrim函数将数值型转为字符型
16.没有cast函数,数值型到字符型转移使用select convert(varchar(10),123)
17.没有replace函数
18.没有left函数,只有right函数
19.不支持在字段上加[]
20.select语句中不支持变量累加,例如:select @sql=@sql+colname from tablename
21.在过程及视图中系统会自动将select * 变为select 列1,列2...
22.varchar最大支持16384个字节(SQLServer中是8000)
23.sybase不支持表变量
24.sybase不支持instead of触发器
25.sybase没有调度(定时执行某个操作)