smo

Is it possible to create a Database in SQL Server with powershell?

一曲冷凌霜 提交于 2019-11-30 06:39:58
I am trying to create a empty database in SQL server using powershell and SMO but cannot seem to find a way of doing it. Is this possible? Connection script for sql server: [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null $serverName = "localhost" $server = new-object ('Microsoft.SqlServer.Management.Smo.Server') $serverName $server.ConnectionContext.LoginSecure=$false; $credential = Get-Credential $loginName = $credential.UserName -replace("\\","") $server.ConnectionContext.set_Login($loginName); $server.ConnectionContext.set_SecurePassword($credential

Programmatically detect SQL Server Edition

Deadly 提交于 2019-11-30 03:44:01
问题 I'm using C# with SMO and attempting to detect what edition of SQL Server (e.g., enterprise, standard) I'm connecting to. I know how to get the version information, but that only tells me what version of SQL Server (e.g., SQL Server 2008 vs SQL Server 2005). Does anyone know how to get the actual product edition (e.g., enterprise, standard)? I need this information because some SQL Server features are only enterprise. Thus, I could just try to call them and catch the exception, but I'd much

SQL Server timeout while restoring databases with SMO

风格不统一 提交于 2019-11-29 15:21:56
I have a .NET application where I restore a number of databases using SMO. The timeout setting in the connection string is set to 0 (unlimited). Most databases restore fine, except one databases that sometimes times out on the restore. The size of it approaches 3 GB. Are there any workarounds for this problem? Is there a setting I am missing. I am using DatabaseRestore object to restore the database. Thanks! M.R. There are two timeout settings for SMO - one is the ConnectionTimeOut settings, and the other is the StatementTimeOut setting - you need to make sure you are setting the right one:

How can I get the return value from Sql Server system message?

廉价感情. 提交于 2019-11-29 11:08:14
I am trying to verify the backup I have just done in c# using command against sql server Express string _commandText = string.Format("RESTORE VERIFYONLY FROM DISK = '{0}'", backupLocation); SqlDataReader _sqlDataReader = SqlHelper.ExecuteReader("BookssortedSQLDbConnection", CommandType.Text, _commandText); If I execute the command in SSMS it returns 'The backup set on file 1 is valid.' but how can I get this message back into my code? A reader wont work as there are no rows being returned. NOTE: I have tried the SMO.Restore object to try and verify it but it doesn't work and that is why I am

Could not load file or assembly microsoft.sqlserver.sqlclrprovider 13.100.0.0

我与影子孤独终老i 提交于 2019-11-29 03:28:35
I run my Winforms app using SQLServer assemblies Microsoft.SqlServer.ConnectionInfo (13.100.0.0) Microsoft.SqlServer.SMO(13.100.0.0) On the same machine SSMS 2016(Aug) is installed. And here SQL 2014 Dev Edition is installed too. WHen I run my app it gives me an error: сonnection = new ServerConnection(instanceName); ------------ Could not load file or assembly ‘microsoft.sqlserver.sqlclrprovider version=13.100.0.0′ I have checked: GAC contains some this assemblies 11, 12, 13.0.0.0, but there is no 13.100.0.0. The application has got referenced assemblies from: C:\Program Files (x86)\Microsoft

Is it possible to create a Database in SQL Server with powershell?

无人久伴 提交于 2019-11-29 02:59:40
问题 I am trying to create a empty database in SQL server using powershell and SMO but cannot seem to find a way of doing it. Is this possible? Connection script for sql server: [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null $serverName = "localhost" $server = new-object ('Microsoft.SqlServer.Management.Smo.Server') $serverName $server.ConnectionContext.LoginSecure=$false; $credential = Get-Credential $loginName = $credential.UserName -replace("\\","")

SQL Server timeout while restoring databases with SMO

放肆的年华 提交于 2019-11-28 09:07:42
问题 I have a .NET application where I restore a number of databases using SMO. The timeout setting in the connection string is set to 0 (unlimited). Most databases restore fine, except one databases that sometimes times out on the restore. The size of it approaches 3 GB. Are there any workarounds for this problem? Is there a setting I am missing. I am using DatabaseRestore object to restore the database. Thanks! 回答1: There are two timeout settings for SMO - one is the ConnectionTimeOut settings,

SQL Server SMO complains of missing DLL

拥有回忆 提交于 2019-11-28 07:39:25
Ok, I've scoured the web, BOL, various forums and I'm no closer to an answer...hopefully you fine folks can lend a hand... We've got a dozen or so SQL Servers (some 2k, some 2005) on a network. I'm using SMO objects in a .NET application to get some standard information. My problem appears to boil down to a missing DLL - Microsoft.SqlServer.BatchParser.dll. However, this DLL did not come with the other SQL DLLs (Microsoft.SqlServer.ConnectionInfo.dll, Microsoft.SqlServer.Smo.dll, Microsoft.SqlServer.SmoEnum.dll, Microsoft.SqlServer.SqlEnum.dll, etc...). I also downloaded the SS2005 feature

How can I get the return value from Sql Server system message?

醉酒当歌 提交于 2019-11-28 04:54:58
问题 I am trying to verify the backup I have just done in c# using command against sql server Express string _commandText = string.Format("RESTORE VERIFYONLY FROM DISK = '{0}'", backupLocation); SqlDataReader _sqlDataReader = SqlHelper.ExecuteReader("BookssortedSQLDbConnection", CommandType.Text, _commandText); If I execute the command in SSMS it returns 'The backup set on file 1 is valid.' but how can I get this message back into my code? A reader wont work as there are no rows being returned.

Could not load file or assembly microsoft.sqlserver.sqlclrprovider 13.100.0.0

ε祈祈猫儿з 提交于 2019-11-27 17:35:11
问题 I run my Winforms app using SQLServer assemblies Microsoft.SqlServer.ConnectionInfo (13.100.0.0) Microsoft.SqlServer.SMO(13.100.0.0) On the same machine SSMS 2016(Aug) is installed. And here SQL 2014 Dev Edition is installed too. WHen I run my app it gives me an error: сonnection = new ServerConnection(instanceName); ------------ Could not load file or assembly ‘microsoft.sqlserver.sqlclrprovider version=13.100.0.0′ I have checked: GAC contains some this assemblies 11, 12, 13.0.0.0, but there