1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- src - https://stackoverflow.com/a/937995
--
-- you cant use 'temporary table variable' aka @variables
-- as doesnt exist after GO - https://www.pipiscrew.com/2020/11/temporary-tables-vs-table-variables-in-sql-server/
CREATE TABLE #variables
(
VarName VARCHAR(20) PRIMARY KEY,
Value VARCHAR(255)
)
GO
Insert into #variables Select 'Bob', 'SweetDB'
GO
Select Value From #variables Where VarName = 'Bob'
GO
DROP TABLE #variables
go
origin - https://www.pipiscrew.com/?p=19407 persist-a-variable-across-go