SET NOCOUNT OFF;
DECLARE @tmp_TableA TABLE (grpName varchar(10),
grpValue varchar(10),
grpID int,
rowID int)
INSERT INTO @tmp_TableA
SELECT 'หอย', 'value1', 1, 1 UNION
SELECT 'หอย', 'value2', 1, 2 UNION
SELECT 'งาม', 'value3', 2, 3 UNION
SELECT 'งาม', 'value4', 2, 4 UNION
SELECT 'เพราะ', 'value5', 3, 5 UNION
SELECT 'เพราะ', 'value6', 3, 6 UNION
SELECT 'ขน', 'value7', 4, 7 UNION
SELECT 'ขน', 'value8', 4, 8 UNION
SELECT 'คน', 'value9', 5, 9 UNION
SELECT 'งาม', 'value10', 6, 10 UNION
SELECT 'เพราะ', 'value11', 7, 11
;WITH cte AS
(
SELECT
ROW_NUMBER() OVER(PARTITION BY grpID ORDER BY grpID ) AS rnum,
grpID
,grpName
FROM @tmp_TableA
)
UPDATE cte SET grpName =''
WHERE rnum > 1
SELECT * FROM @tmp_TableA ORDER BY grpID
GO
Public Shared Function FuckStoreProcedure(ByVal k1 As Integer, ByVal k2 As String) As DataTable
Dim s As XCData =
<![CDATA[SET NOCOUNT OFF;
DECLARE @tmp_TableA TABLE (grpName varchar(10),
grpValue varchar(10),
grpID int,
rowID int)
INSERT INTO @tmp_TableA
SELECT 'หอย', 'value1', 1, 1 UNION
SELECT 'หอย', 'value2', 1, 2 UNION
SELECT 'งาม', 'value3', 2, 3 UNION
SELECT 'งาม', 'value4', 2, 4 UNION
SELECT 'เพราะ', 'value5', 3, 5 UNION
SELECT 'เพราะ', 'value6', 3, 6 UNION
SELECT 'ขน', 'value7', 4, 7 UNION
SELECT 'ขน', 'value8', 4, 8 UNION
SELECT 'คน', 'value9', 5, 9 UNION
SELECT 'งาม', 'value10', 6, 10 UNION
SELECT 'เพราะ', 'value11', 7, 11
;WITH cte AS
(
SELECT
ROW_NUMBER() OVER(PARTITION BY grpID ORDER BY grpID ) AS rnum,
grpID
,grpName
FROM @tmp_TableA
)
UPDATE cte SET grpName = ''
WHERE rnum > 1;
SELECT * FROM @tmp_TableA ORDER BY grpID;
--GO
--GO
--GO
--GO WITH ME.
]]>
Dim dt = FuckStoreProcedure.Query(FormatSQLText(s.Value))
Return dt
End Function