I'm trying to get the assignment of a variable inside a select which runs inside an insert.
INSERT INTO myTable
(Value1,Value2,Value3)
VALUES
(
(
SELECT 'SomeText' + @MyGuid = lower(convert(varchar(36), newid())) + '"Some more text" />' AS Value1,
@MyGuid AS Value2,
columnX AS Value3 FROM myOtherTable));
Essentially, I need to use the same variable twice, but the assignment gets flagged with
Incorrect syntax near '='.
I tried changing the assignment syntax, but it did not help. I need the Guids to be the same. Is it possible to do so?