I am not sure how does it called, so I am not sure how to search for my need.
My MS SQL query:
UPDATE temp
SET temp.x = (SELECT CONVERT(DATE, right(right('0'
+ cast((select s.col1 from table1 s where temp.id=s.id) as nvarchar(8)), 8), 4)
+ left(right('0'
+ cast((select s.col1 from table1 s where temp.id=s.id) as nvarchar(8)), 8), 4))
)
I want to define a variable for this subquery select s.col1 from table1 s where temp.id=s.id
. Something like SET mysubquery ofquerytype= select s.col1 from table1 s where temp.id=s.id
. Then I could reuse the mysubquery
.