老顾请进---> XSL 中xsl:variable 等的用法
你以前回过的帖子
http://topic.csdn.net/u/20080121/17/ec79e414-296d-4937-b3b8-a860335d96b5.html
中
<xsl:for-each select="//company[count(.|key('company_group',./text())[1])=1]">
select 后面的跟我讲解下
谢谢
------最佳解决方案--------------------你去查下xml sdk里 xsl:key的用法,一下就明白了。
------其他解决方案----------------------Customer为目标表,CustomerStage为原表,当原表匹配目标表时更新,否则插入, 当目标表不匹配原表时删除
MERGE INTO Customer AS TGT
USING dbo.CustomerStage AS SRC
ON TGT.CUSID=SRC.CUSID
WHEN MATCHED THEN
UPDATE SET
TGT.CustomeName=SRC.CustomeName,
TGT.companyname=SRC.companyname
WHEN NOT MATCHED THEN
INSERT (CUSID,CustomeName,companyname)
VALUES (SRC.CUSID,SRC.CustomeName,SRC.companyname)
WHEN NOT MATCHED BY SOURCE THEN
DELETE;
------其他解决方案----------------------OUTPUT CLAUSE
--1 INSERT WITH OUTPUT
IF OBJECT_ID('Rows') IS NOT NULL DROP TABLE ROWS
CREATE TABLE [ROWS](COL INT IDENTITY(1,1),DATACOL VARCHAR(20))
INSERT INTO [ROWS]
OUTPUT inserted.COL,inserted.DATACOL
SELECT COMPANYNAME FROM Customer
--RESULTS
COL DATACOL
----------- --------------------
1 Microsoft
2 Intel
3 alibaba
4 siemens
5 Bank
6 GOOGLE
(6 row(s) affected)
-- DELETE WITH OUTPUT
DELETE FROM [ROWS]
OUTPUT deleted.COL,
deleted.DATACOL
WHERE COL<10
-- UPDATE WITH OUTPUT
UPDATE [ROWS]
SET DATACOLDATACOL=DATACOL+'--'
OUTPUT inserted.COL,
deleted.DATACOL AS OLDDATA,
inserted.DATACOL AS NEWDATA
WHERE COL<11
--RESULTS
COL OLDDATA NEWDATA