0

Is there nay way that my application could create a new instance (say MyInstance) and attach my DB to that, with sa password?

Please give me vb.net code for it if possible.

Thanks a lot.

1 Answer 1

1

I don't think so! You can only create an instance through SQL Server installation, there is no code for that.

The attachment yes can be done through code, you just need to add FOR ATTACH on your CREATE DATABASE command.

Can you share why you want to create a new instance? I don't see why this would be necessary on a application.

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

4 Comments

The reason why I need my own instance is so my DB could be attached to that without knowing sa password. I have seen several articles over net which tell you how to do it, but got stuck at certain stage. Please refer to codeproject.com/Articles/28188/…
This not only installs the SQL server express automatically but also installs new instance and attached DB without involving sa
You want to install a new instance of SQL purely to rest the SA password? Why not give the user a username/password dialogue so they can enter the sa password?
Yes, u are right Rene but I want to explore how making a new instance works. Anyway, your idea is not bad either.

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.