Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Creating a Database

Author  Topic 

lwestj
Starting Member

1 Post

Posted - 2004-04-12 : 22:24:52
I am developing a program where I would like the end-user to be able to click the New Company menu and it creates a new datasource with a different name leaving the default datasource alone (blank). I am new to SQL Server (using 2000) and VB6. I know how to do this with a Access back-end, but need help in doing this with SQL Server. Any help would be appreciative and thanks in advance.

kroky
Starting Member

14 Posts

Posted - 2004-04-14 : 04:12:22
You can script your blank db (in enterprise manager rightclick on table sp or whatever generate SQL script and click the Script all objects) so EM will buid a script of the DB you need to create (actualy you need to copy it if i have understood correctly) and afterwards reed the script to parameterise the dbname and whatever is needed so you can create a SP which will execute this script.

Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-14 : 09:39:55
If you are wanting to create a new database with a new user:

For example: A lot of web companies when you sign up will set up a database for you with a paramater you give them.
Database: ??
User: ??
Password: ??

You need to look at the following in Books Online:

CREATE DATABASE
sp_addlogin (creates a new SQL Server login)
sp_grantdbaccess (gives a login access to a specific database)

Be sure to set the default database when you run sp_addlogin.

If you need help after seeing the scripts in Books Online, let us know and we can help you out.


MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -