Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
Im using the Azure Data Studio to build an .sqlproj which later on I use it in order to build and deploy a .dacpac file via Azure Pipelines to an Azure Database (SQL Server).
I'm creating user, roles, permissions .... Everything was going smoothly.
At some point I created a folder xxxxx and created an .sql file in it.
The file looks like that:
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'xxxxxx')
BEGIN
PRINT 'creating user: [xxxxxxx]...'
CREATE USER [xxxx] FROM EXTERNAL PROVIDER;
GRANT yyyyyy TO [xxxxxxxx];
PRINT 'adding [xxxxxxxx] to role: [zzzzzzzz]'
ALTER ROLE [zzzzzzzzz] ADD MEMBER [xxxxxxxxx];
END
.
.
.
From this point on when building the database project, I started receiving a
Build error SQL70001: This statement is not recognized in this context.
The .sqlproj contains the line which points to the location where the .sql file is:
It seems that despite it creates schema objects (but initially checks if the object is already there), this statements need to go the Script.PostDeployment1.sql script.
Im using the Azure Data Studio to build an .sqlproj which later on I use it in order to build and deploy a .dacpac file via Azure Pipelines to an Azure Database (SQL Server).
I'm creating user, roles, permissions .... Everything was going smoothly.
At some point I created a folder
xxxxx
and created an.sql
file in it.The file looks like that:
From this point on when building the database project, I started receiving a
The .sqlproj contains the line which points to the location where the .sql file is:
I realized from this issue (https://github.com/microsoft/azuredatastudio/issues/24125):
Only CREATE statements are supported in sql projects
Neverheless, its not complaining with an .sql script file which seems like this:
What even context means in this case? Is there any documentation on what is allowed and what not? Any ideas on what it can go wrong?
I also saw this issue (https://github.com/microsoft/DacFx/issues/88) but its not clear to me what needs to be done.
It seems that despite it creates schema objects (but initially checks if the object is already there), this statements need to go the
Script.PostDeployment1.sql
script.