, Guest>> || || |
/ Microsoft SQL Server
  XML  [new]
BKV88
Member

:
: 243
!
XML
.
,

:

<?xml version="1.0" encoding="windows-1251"?>< xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="11111" ="11" ="11">
< ="0000080" ="1" 8="0">
< ="22050338.95">
< ="1" ="11"
="01.04.2015" ="4588" ="6554,64">
<>01</>
<>01.04.2015</>
<>
< ="2222" ="222"></>
</>
</>
< ="2" ="11"
="01.04.2015" ="4588" ="6554,64">
<>01</>
<>01.04.2015</>
<>
< ="111" ="111"></>
</>
</>
</>
</>
</>


:

DROP Table #Book8
GO

CREATE TABLE #Book8(
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL
)

INSERT INTO #Book8 VALUES ('1','01','11','01.04.2015','01.04.2015','2222','222','4588','6554,64')
INSERT INTO #Book8 VALUES ('2','01','11','01.04.2015','01.04.2015','111111','1111','4 540,00','692,54')




declare @t1 table	(
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL
					)
declare @filename varchar(255)
		,@xml nvarchar(max)
		,@FS int
		,@OLEResult int
		,@FileID int

insert into @t1
select	 *
from	#Book8
where []=1
 

set @filename = 'D:\111.xml'
set @xml =   N'<?xml version="1.0" encoding="windows-1251"?>' +
N'< xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="111" ="11" ="11">'+
N'< ="0000080" ="1" 8="0">'+
N'< ="22050338.95">'+
N'< ="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'"
="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'">'+ 
N'<>'+(select [] from @t1)+'</>'+
N'<>'+(select [] from @t1)+'</>'+
N'<>'+
N'< ="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'">'+
N'</>'+
N'</>'+
N'</>'+
N'</>'+
N'</>'+
N'</>'
execute @OLEResult = sp_OACreate 'Scripting.FileSystemObject', @FS OUTPUT
execute @OLEResult = sp_OAMethod @FS,'CreateTextFile',@FileID OUTPUT, @FileName
execute @OLEResult = sp_OAMethod @FileID,'OpenAsTextStream(ForWriting, 2)'
execute @OLEResult = sp_OAMethod @FileID, 'Write', NULL, @xml
execute @OLEResult = sp_OADestroy @FileID
execute @OLEResult = sp_OADestroy @FS
select	@filename
13 15, 19:05[18274484]      |
 Re: XML  [new]
BKV88
Member

:
: 243
:

< ="2" ="11"
="01.04.2015" ="4588" ="6554,64">
<>01</>
<>01.04.2015</>
<>
< ="111" ="111"></>
</>
</>
13 15, 19:07[18274487]      |
 Re: XML  [new]
yaxta
Member

: ,
: 518
BKV88
!
XML
.
,

:

<?xml version="1.0" encoding="windows-1251"?>< xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="11111" ="11" ="11">
< ="0000080" ="1" 8="0">
< ="22050338.95">
< ="1" ="11"
="01.04.2015" ="4588" ="6554,64">
<>01</>
<>01.04.2015</>
<>
< ="2222" ="222"></>
</>
</>
< ="2" ="11"
="01.04.2015" ="4588" ="6554,64">
<>01</>
<>01.04.2015</>
<>
< ="111" ="111"></>
</>
</>
</>
</>
</>


:

DROP Table #Book8
GO

CREATE TABLE #Book8(
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL
)

INSERT INTO #Book8 VALUES ('1','01','11','01.04.2015','01.04.2015','2222','222','4588','6554,64')
INSERT INTO #Book8 VALUES ('2','01','11','01.04.2015','01.04.2015','111111','1111','4 540,00','692,54')




declare @t1 table	(
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL
					)
declare @filename varchar(255)
		,@xml nvarchar(max)
		,@FS int
		,@OLEResult int
		,@FileID int

insert into @t1
select	 *
from	#Book8
where []=1
 

set @filename = 'D:\111.xml'
set @xml =   N'<?xml version="1.0" encoding="windows-1251"?>' +
N'< xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="111" ="11" ="11">'+
N'< ="0000080" ="1" 8="0">'+
N'< ="22050338.95">'+
N'< ="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'"
="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'">'+ 
N'<>'+(select [] from @t1)+'</>'+
N'<>'+(select [] from @t1)+'</>'+
N'<>'+
N'< ="'+(select [] from @t1)+'" ="'+(select [] from @t1)+'">'+
N'</>'+
N'</>'+
N'</>'+
N'</>'+
N'</>'+
N'</>'
execute @OLEResult = sp_OACreate 'Scripting.FileSystemObject', @FS OUTPUT
execute @OLEResult = sp_OAMethod @FS,'CreateTextFile',@FileID OUTPUT, @FileName
execute @OLEResult = sp_OAMethod @FileID,'OpenAsTextStream(ForWriting, 2)'
execute @OLEResult = sp_OAMethod @FileID, 'Write', NULL, @xml
execute @OLEResult = sp_OADestroy @FileID
execute @OLEResult = sp_OADestroy @FS
select	@filename




13 15, 19:45[18274576]      |
 Re: XML  [new]
felix_ff
Member

: Moscow
: 1698
BKV88,

.

IF OBJECT_ID('tempdb..#Book8') IS NOT NULL DROP Table #Book8
GO

CREATE TABLE #Book8(
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL,
	[] [varchar](255) NULL
)

INSERT INTO #Book8 VALUES ('1','01','11','01.04.2015','01.04.2015','2222','222','4588','6554,64')
INSERT INTO #Book8 VALUES ('2','01','11','01.04.2015','01.04.2015','111111','1111','4 540,00','692,54')

SET NOCOUNT ON
DECLARE
       @FileID INT,
       @Version VARCHAR(20),
       @FormatVersion VARCHAR(20),
       @DocID VARCHAR(20),
       @DocNumCorr INT,
       @DocFlag INT,
       @NdsSumm VARCHAR(20),
       @xml_string VARCHAR(MAX),
       @xml XML

SELECT @FileID = 11111,
       @Version = '11',
       @FormatVersion = '11',
       @DocID = '0000080',
       @DocNumCorr = 1,
       @DocFlag = 0,
       @NdsSumm = '22050338.95'

SET @xml_string = '<?xml version="1.0" encoding="windows-1251"?>'

SET @xml_string = @xml_string + CAST(
(
SELECT
      @DocID AS '@',
      @DocNumCorr AS '@',
      @DocFlag AS '@8',
      @NdsSumm AS '/@',
      (SELECT [] AS '@',
              [] AS '@',
              [] AS '@',
              [] AS '@',
              [] AS '@',
              [] AS [],
              [] AS [],
              [] AS '//@',
              [] AS '//@'
       FROM #Book8 FOR XML PATH(''), TYPE) AS ''
FOR XML PATH(''), TYPE) AS VARCHAR(MAX))

SET @xml = CONVERT(XML, @xml_string)

;WITH XMLNAMESPACES ( 'http://www.w3.org/2001/XMLSchema-instance' AS xsi )  
SELECT @FileID AS '@',
       @Version AS '@',
       @FormatVersion AS '@',
       @xml
FOR XML PATH('')


14 15, 00:25[18275432]      |
/ Microsoft SQL Server