Error: ‘CREATE VIEW’ must be the first statement in a query batch
the issue: receive the following error while trying to run your .sql file:
Error: 'CREATE VIEW' must be the first statement in a query batch. SQLState: S0001 ErrorCode: 111
your file might look like this…
drop view view1; create view view1....
the solution: try wrapping it with “exec(”)”
drop view view1; exec('create view view1...')
Note: if you have single quotes in your create statement escape them with a single quote, example:
exec('CREATE VIEW theView ("id") as select a.id from tableA a where a.name = ''test'' ')