| David Thielen 2006-11-15, 12:14 am |
| You guys are on a roll tonight - perfect - thanks
--
thanks - dave
david_at_windward_do
t_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
"Peter Yang [MSFT]" wrote:
> Hello Dave,
>
> I understand that you'd like to create database dynamically by using the
> name the user inputs. Also, you'd like to select the user owns the created
> database.
>
> As far as I know, you could not pass a parameter to "create database"
> statment as the database name. However, you could construct a string so
> that you could execute the string directly.
>
> declare @db varchar(50)
> select @db='testdb'
> select @db='create database ' +@db
> Execute (@db)
>
> You could run "select * from master..syslogins" to get all logins including
> SQL and domain users and you way want to filter ntgroup by using isntgroup
> column. You may want to use sp_changedbowner after creating the database.
>
> Also, you could use SMO (2005) or DMO (2000) to create database
> dynamically. Please refer to the following articles for details:
>
> Database Class
> http://msdn2.microsoft.com/en-us/li...management.smo.
> database.aspx
>
> How to: Create, Alter, and Remove a Database in Visual Basic .NET
> http://msdn2.microsoft.com/en-us/library/ms162576.aspx
>
> Create database in sql server using asp.net with C#
> http://www.codeproject.com/useritem...te_Database.asp
>
> As for database owner, you could use SetOwener method in SMO to set owner
> of the database. Also, you could enumerate logins in server object to get
> all logins on the server:
>
> Database.SetOwner Method
> http://msdn2.microsoft.com/en-us/li...management.smo.
> database.setowner.aspx
>
> Server.Logins Property
> http://msdn2.microsoft.com/en-gb/li...management.smo.
> server.logins.aspx
>
> Logins Collection
> http://msdn.microsoft.com/library/e...2.asp?frame=tru
> e
>
> In DMO there is no method to set owner when creating database. However, you
> could run sp_changedbowner after you create the database.
>
> If you have any further concerns or comments, please feel free to let's
> know. Thank you.
>
> Best Regards,
>
> Peter Yang
> MCSE2000/2003, MCSA, MCDBA
> Microsoft Online Community Support
> ====================
====================
==========
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscript...ault.aspx#notif
> ications
> <http://msdn.microsoft.com/subscript...ps/default.aspx>.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> <http://msdn.microsoft.com/subscript...rt/default.aspx>.
> ====================
====================
==========
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
|