1
2 create procedure sp_drv_gettypes(@sstype int = 0, @usertype int = 0)
3 as
4 declare @cmd varchar(500)
5
6 select @cmd = ' select name=case
7 when b.usertype=18 then ''sysname''
8 when b.usertype=25 then ''nvarchar''
9 when b.usertype=42 then ''longsysname''
10 when b.usertype=80 then ''timestamp''
11 when b.usertype=24 then ''nchar''
12 when a.ss_dtype=111 then ''datetimn''
13 when a.ss_dtype=109 then ''floatn''
14 else local_type_name end,
15 a.ss_dtype,
16 b.usertype
17 from sybsystemprocs.dbo.spt_datatype_info a,
18 systypes b
19 where a.ss_dtype=b.type '
20
21 if @sstype > 0 and @usertype > 0
22 begin
23 select @cmd = @cmd + ' and a.ss_dtype=' + convert(varchar(10), @sstype) + ' and b.usertype=' + convert(varchar(10), @usertype)
24
25 end
26 else if @sstype = 0 and @usertype = 0
27 begin
28 select @cmd = @cmd
29 end
30 else if @sstype = 0
31 begin
32 select @cmd = @cmd + ' and b.usertype=' + convert(varchar(10), @usertype)
33
34 end
35 else if @usertype = 0
36 begin
37 select @cmd = @cmd + ' and a.ss_dtype=' + convert(varchar(10), @sstype)
38 end
39
40 --select @cmd
41 execute (@cmd)
42
43
exec sp_procxmode 'sp_drv_gettypes', 'AnyMode'
go
Grant Execute on sp_drv_gettypes to public
go