Recently I came across the need to insert the same unique identifier into two separate columns in the same insert statement. It turns out that it is a relatively easy solution but something that took a little bit of ingenuity.
So it’s not often, in fact I can’t think of many instances where you would need to insert the same unique identifier into two different columns in a single table in a single insert statement. As you may or may not know the easiest way to get a new unique identifier in T-SQL is using the command NEWID(). However, the problem is that if you make this call twice in a single statement you’ll get two unique identifiers.