1 /** SECTION END: CLEANUP **/
2
3 create procedure sp_jdbc_convert_datatype(
4 @source int,
5 @destination int)
6 as
7
8 if @@trancount = 0
9 begin
10 set chained off
11 end
12
13 set transaction isolation level 1
14
15 /* Make source non-negative */
16 select @source = @source + 7
17 /* Put the strange date numbers into this area between 0-19*/
18 if (@source > 90)
19 select @source = @source - 82
20
21 /*Convert destination the same way*/
22 /* Put the strange date numbers into this area between 0-19*/
23 if (@destination > 90)
24 select @destination = @destination - 82
25
26 /* Need 8 added instead of 7 because substring starts at 1 instead */
27 /* of 0 */
28 select @destination = @destination + 8
29
30 /* Check the conversion. If the bit string in the table has a 1
31 ** on the place's number of the destination's value we have to
32 ** return true, else false
33 */
34 if ((select substring(conversion, @destination, 1)
35 from master.dbo.spt_jdbc_conversion
36 where datatype = @source) = '1')
37
38 select 1
39 else
40 select 0
41
exec sp_procxmode 'sp_jdbc_convert_datatype', 'AnyMode'
go
Grant Execute on sp_jdbc_convert_datatype to public
go