程序員經常問我在SQL Server
如果前端或中間層的代碼將數據轉給XML格式的存儲過程
<orders>
<OrderID> <OrderID/>
<CustomerID> <CustomerID/>
<EmployeeID> <EmployeeID/>
<OrderDate> <OrderDate/>
<RequiredDate> <RequiredDate/>
<ShippedDate> <ShippedDate/>
<ShipVia> <ShipVia/>
<Freight> <Freight/>
<ShipName> <ShipName/>
<ShipAddress> <ShipAddress/>
<ShipCity> <ShipCity/>
<ShipRegion> <ShipRegion/>
<ShipPostalCode> <ShipPostalCode/>
<ShipCountry> <ShipCountry/>
</orders>
一旦程序員擁有圖表的XML框架
不幸的是
CREATE PROCEDURE dbo
@table_name VARCHAR(
@owner_name VARCHAR(
)
AS
SET NOCOUNT ON
/* table variable to hold values */
DECLARE @temp TABLE (
string_value VARCHAR(
)
/* check if the table exists */
IF NOT EXISTS (
SELECT a
FROM sysobjects a INNER JOIN sysusers b
ON a
AND a
AND a
AND b
BEGIN
RAISERROR(
RETURN
END
INSERT @temp
SELECT
/* append a few blank spaces to make the output readable */
INSERT @temp
SELECT
+
FROM inlumns
WHERE
table_name = @table_name
AND
table_schema = @owner_name
ORDER BY ordinal_position
INSERT @temp
SELECT
一旦存儲過程生成
EXEC get_table_xml_structure
From:http://tw.wingwit.com/Article/program/SQLServer/201311/22001.html