/****** Object:  UserDefinedFunction [dbo].[fnx_GetDispChildXml_privivki]    Script Date: 21.10.2016 11:05:07 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fnx_GetDispChildXml_privivki]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[fnx_GetDispChildXml_privivki]
GO
--/****** Object:  UserDefinedFunction [dbo].[fnx_GetDispChildXml_privivki]    Script Date: 21.10.2016 11:05:07 ******/
--SET ANSI_NULLS ON
--GO

--SET QUOTED_IDENTIFIER ON
--GO
--CREATE FUNCTION [dbo].[fnx_GetDispChildXml_privivki](@Vactination [int])
--RETURNS @priv TABLE (
--	[Split] [varchar](8) NULL
--) WITH EXECUTE AS CALLER
--AS 
--BEGIN
--	if @Vactination & 2 = 2 begin insert into @priv (split) values('6') end
--	if @Vactination & 4 = 4 begin insert into @priv (split) values('7') end
--	if @Vactination & 8 = 8 begin insert into @priv (split) values('8') end
--	if @Vactination & 16 = 16 begin insert into @priv (split) values('9') end
--	if @Vactination & 32 = 32 begin insert into @priv (split) values('10') end
--	if @Vactination & 64 = 64 begin insert into @priv (split) values('11') end
--	if @Vactination & 128 = 128 begin insert into @priv (split) values('12') end
--	if @Vactination & 256 = 256 begin insert into @priv (split) values('13') end
--	if @Vactination & 512 = 512 begin insert into @priv (split) values('14') end
--	if @Vactination & 1024 = 1024 begin insert into @priv (split) values('15') end
--	if @Vactination & 2048 = 2048 begin insert into @priv (split) values('16') end
--	if @Vactination & 4096 = 4096 begin insert into @priv (split) values('18') end
--	if @Vactination & 8192 = 8192 begin insert into @priv (split) values('19') end
--	if @Vactination & 16384 = 16384 begin insert into @priv (split) values('20') end
--	if @Vactination & 32768 = 32768 begin insert into @priv (split) values('21') end
--	if @Vactination & 65536 = 65536 begin insert into @priv (split) values('22') end
--	if @Vactination & 131072 = 131072 begin insert into @priv (split) values('23') end
--	if @Vactination & 262144 = 262144 begin insert into @priv (split) values('24') end
--	if @Vactination & 524288 = 524288 begin insert into @priv (split) values('25') end
--	if @Vactination & 1048576 = 1048576 begin insert into @priv (split) values('26') end
--	if @Vactination & 2097152 = 2097152 begin insert into @priv (split) values('27') end
--	if @Vactination & 4194304 = 4194304 begin insert into @priv (split) values('28') end
-- RETURN 
--END

