/*
'bcp' is not recognized as an internal or external command or operable program?
Check if there is a bcp.exe file in C:Program FilesMicrosoft SQL Server80ToolsBinn
Then add C:Program FilesMicrosoft SQL Server80ToolsBinn to the path and see if there is no such directory.
Right-click My Computer--Properties- -Advanced--Environment variables--Find path in system variables--Edit
Add at the end of the variable value:
C:Program FilesMicrosoft SQL Server80ToolsBINN
*/
/***************************************************** ******************
Stored procedure: P_SaveXML
Function: Generate XML file
Parameters: Table name
Return: XML file in the specified directory
Calling method: Pass the table name that exists in the intermediate table TB_TABLECOLUMN_T
exec P_ZehuaSavexml 'WQ_STINFO_B,WQ_PHY_D','D:xx.xml'
Last change date: 2005-8-17
Contact information: zlp@zehua.com.cn
Remarks: Generate XML files in standard format based on the intermediate table
www.knowsky.com
********************** *************************************************** ***/
/*
exec P_ZehuaSavexml 'WQ_STINFO_B,WQ_PHY_D','D:xx.xml'
*/
go
create proc P_ZehuaSavexml
@TableCodeS varchar(8000) ,
@fname varchar(1000)='c: mp.xml' --Default saved XML file address
as
declare @sql nvarchar(200),@sql1 varchar(400)
declare @cnt int,@Table_Name varchar(20)
declare @i int,@TableCode varchar(20)
declare @err int,@src varchar(255),@desc varchar(255)
create table ##t(re nvarchar(4000))
insert ##t
select Re=''
union all select '
set @i=charindex(',',@TableCodeS)
while @i>0
begin
set @TableCode=left(@TableCodeS,@i-1)
set @sql=''
set @sql=N'select @cnt=count(*),@Table_Name=max(Table_Name) from '
set @sql=@sql N'('
set @sql=@sql N'select top 100 percent * from TB_TABLECOLUMN_T where '
set @sql=@sql N'TABLE_CODE=''' @TableCode ''' and COLUMNS_ISKEY=''√'' '
set @sql=@sql N'order by COLUMNS_SORT '
set @sql=@sql N')'