Sample For Lamak

0

Please login or register to vote for this query.

(click on this box to dismiss)

Enter Query Description

Stack Overflow

Q&A for programmers

-- Enter Query Title
-- Enter Query Description

Declare @Table as table (name varchar(20), activity varchar(20) , SpecialID uniqueidentifier)


INSERT INTO @Table 
(name, activity)
values
('James','Running'),    
('James','Running'),
('James','Walking'),
('John','Running'),
('John','Running'),
('John','Walking')


;WITH TableId AS
(
    SELECT DISTINCT Name, activity
    FROM @Table
)
UPDATE @Table
SET A.SpecialId = B.SpecialId
FROM @Table A
INNER JOIN (SELECT Name, Activity, NEWID() SpecialId FROM TableId) B
ON A.Name = B.Name AND A.Activity = B.activity


SELECT * FROm @Table

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached