sqldmo

SQL SMO - checking if a user is a server admin

非 Y 不嫁゛ 提交于 2019-12-11 03:22:05
问题 I want to check if the connected user is a SQL Server admin (in the sysadmin role) and wondering if this is this is the best way to do it? private static bool IsUserAdmin(Server server) { Login login = server.Logins[server.ConnectionContext.Login]; return login.IsMember("sysadmin"); } In SQL DMO (the COM based predecessor to SMO) there was a property that hung off the SQLDMO.SQLServer object called IsServerAdmin . I'm wondering if there's something similar in SMO but that I just haven't been

SQL Server 2008 alternative for SQL-DMO

爷,独闯天下 提交于 2019-12-08 03:56:46
问题 I previously was using SQL-DMO to automatically generate scripts from the database. Now I upgraded to SQL Server 2008 and I don’t want to use this feature anymore since Microsoft will be dropping this feature off. Is there any other alternative I can use to connect to a server and generate scripts automatically from a database? Any answer is welcome. Thanks in advance. This is the procedure i was previously using: CREATE PROC GenerateSP ( @server varchar(30) = null, @uname varchar(30) = null,

SQL Server 2008 alternative for SQL-DMO

ε祈祈猫儿з 提交于 2019-12-06 14:48:51
I previously was using SQL-DMO to automatically generate scripts from the database. Now I upgraded to SQL Server 2008 and I don’t want to use this feature anymore since Microsoft will be dropping this feature off. Is there any other alternative I can use to connect to a server and generate scripts automatically from a database? Any answer is welcome. Thanks in advance. This is the procedure i was previously using: CREATE PROC GenerateSP ( @server varchar(30) = null, @uname varchar(30) = null, @pwd varchar(30) = null, @dbname varchar(30) = null, @filename varchar(200) = 'c:\script.sql' ) AS