/*
Isn't 'bcp' an internal or external command or a program that can be run?
Check whether the bcp.exe file exists in C: Program FilesMicrosoft SQL server80toolsbinn.
Check whether the directory C: Program FilesMicrosoft SQL Server80ToolsBinn is added to the path.
Right-click my computer -- properties -- Advanced -- environment variables -- find path in system variables -- edit
Add the following at the end of the variable value:
C: Program FilesMicrosoft SQL Server80ToolsBINN
*/
/*************************************** *******************************
Stored Procedure: P_SaveXML
Function: generate an XML file.
Parameter: Table Name
Return: XML file of the specified directory
Call method: Pass the name of the table in the middle table TB_TABLECOLUMN_T
Exec P_ZehuaSavexml 'wq _ STINFO_ B, WQ_PHY_D ', 'd: xx. xml'
Last modified Date:
Contact: zlp@zehua.com.cn
Note: generate XML files in the 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 = '<? Xml version = "1.0" encoding = "gb2312"?> '
Union all select '<ZehuaTableInfoXml>'
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 ')'