Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying create a database and connect it to Airflow to use it instead of it defaulting to SQLite. However, I am getting an error.

This is my SQL code:

SQL
CREATE DATABASE airflow;
ALTER DATABASE airflow SET READ_COMMITTED_SNAPSHOT ON;
CREATE LOGIN airflow_user WITH PASSWORD='airflow_pass123%';
USE airflow;
CREATE USER airflow_user FROM LOGIN airflow_user;
GRANT ALL PRIVILEGES ON DATABASE airflow TO airflow_user;

And this is the error:

Query 1 ERROR: Msg: 156, Line 7, State: 1, Level: 15
Incorrect syntax near the keyword 'TO'.


What I have tried:

I tried Googling the error, but with no success. Even following the exact syntax from the official doc did not help me.
Posted
Updated 16-Feb-22 9:11am
v2

Change this

SQL
GRANT ALL PRIVILEGES ON DATABASE airflow TO airflow_user;

to
SQL
GRANT CONTROL ON DATABASE::airflow TO airflow_user;
 
Share this answer
 
The documentation at GRANT Database Permissions (Transact-SQL) - SQL Server | Microsoft Docs[^] suggests that the correct syntax is:
SQL
GRANT ALL PRIVILEGES TO airflow_user;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900