December 2001
Intermediate to advanced
800 pages
17h 55m
English
Because array elements can store nearly any type of data, they can also store handles to other arrays. This means that you can easily set up multidimensional arrays and that these arrays can be of either the jagged or the smooth variety. Here's an example:
DECLARE @yhdl int, @xhdl int, @xsiz int, @ysiz int, @res int, @xcnt int, @ycnt int SELECT @ysiz=20, @xsiz=10 -- Allocate the y dimension SET @yhdl=fn_createarray(@ysiz) -- Allocate and fill each row SET @ycnt=1 WHILE @ycnt<=@ysiz BEGIN SET @xhdl=fn_createarray(@xsiz) SET @res=fn_setarray(@yhdl,@ycnt,@xhdl) SET @xcnt=1 WHILE @xcnt<=@xsiz BEGIN SET @res=fn_setarray(@xhdl,@xcnt,RAND()*100) SET @xcnt=@xcnt+1 END SET @ycnt=@ycnt+1 END -- List each row SET @ycnt=1 WHILE @ycnt<=@ysiz ...
Read now
Unlock full access