0

I am creating a copy of database in Azure through c# code.

Code for creating database:

CREATE DATABASE ABC AS COPY OF DEF

Then I want to create a user in that database so that only that user can access the database. This code executes as soon as the database is created. but while creating a user I get an error:

"failed to update database because the database is read only".

If I stop the execution for 15-20 seconds, then start, it works perfectly, but I don't want to do that.

Can I get some status that the database is created and you can proceed.

Any help would be greatly appreciated.

1 Answer 1

2

It appears that you're connecting to your database and executing T-SQL, you may have to use a query against sys.dm_operation_status and find your Create Database command and whether it has completed. There may be an associated REST API if you choose to program this through REST calls, there is a Get Create or Update Server Status call which might fit your scenario.

You will find that the new database will take some time to create and you won't exit that logic instantly in either approach.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank u Dan. The Issue got solved when I used the Api.
Glad to hear it, hope you find success using SQL Azure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.