select newid() as guid, col1, col2, col3
from table1
where ......
from table1
where ......
那么如何让选出的所有行,都拥有相同的uid呢,其实很简单,利用inner join
SELECT g.guid, a.col1, a.col2, a.col3
FROM table1 a inner JOIN (SELECT TOP 1 newid() AS guid) g ON 1 = 1
FROM table1 a inner JOIN (SELECT TOP 1 newid() AS guid) g ON 1 = 1