Hello!
Is there a way in MSSQL liquibase to declare a variable from one sql and then used in another sql?
Example below where first sql declared @User, but second sql will error with “Must declare scalar variable @User”
I need to define them separately because the @User is used multiple times in my project.
I also cannot use the liquibase properties substitution because we need the original sql files to be still compatible with non-liquibase execution.
<databasechangelog>
<changeSet author="liquibase-docs" id="sql-example">
<sql>
SET QUOTED_IDENTIFIER ON
declare @User sysname
select @User = user_name()
</sql>
<sql>
select @User
</sql>
</changeSet>
</databasechangelog>
Thank you.