smo

Failure to CREATE TABLE in SQL Azure database using SMO

…衆ロ難τιáo~ 提交于 2021-02-08 08:16:50
问题 Since USE [dbname] is not supported in SQL Azure, I'm trying to connect to my SQL Azure database by specifying the database name in the connection string and then executing CREATE TABLE... script. However, this fails with System.Data.SqlClient.SqlException "CREATE TABLE permission denied in database 'master'." What am I doing wrong here that it is trying to execute this statement against master? Here is a sample C# code: string connectionString = @"Data Source=tcp:MYSERVER.database.windows

Transferring Data by SMO failing when using ObjectList

时光怂恿深爱的人放手 提交于 2021-02-07 19:53:15
问题 I can transfer all data from a source DB to a target DB by using the option CopyAllTables = true and not providing a list in ObjectList. ServerConnection conn = new ServerConnection(sourceServer); conn.LoginSecure = true; Server srvSource = new Server(conn); Database dbSource = srvSource.Databases[sourceDB]; Transfer xfr = new Transfer(dbSource); xfr.CopyAllTables = true; xfr.Options.WithDependencies = false; xfr.Options.ContinueScriptingOnError = false; xfr.DestinationDatabase = destDB; xfr

Dropping Users from SQL Server Database via Powershell

末鹿安然 提交于 2021-01-28 08:31:13
问题 I am trying to drop users from a SQL server database via PowerShell using the following code: $sql_server = "mysqlserver" $dbname = "mydb" [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server")($sql_server) $db = $server.Databases["$dbname"] $logins = $db.users if ($logins.count -gt 0) { foreach ($login in $logins) { if ($login -notmatch "\[dbo\]|\[guest\]|\[INFORMATION_SCHEMA\]|\[sys\]") {

In PowerShell, pass a complex object (SmoServer) to a background job in the ArgumentList - stuck in “NotStarted”

家住魔仙堡 提交于 2020-12-15 06:45:33
问题 I am trying to pass a pre-built SmoServer object to a background job, to parallelize some operations against multiple SQL Servers. However, when I try to do this, the Child job of the invoked job gets stuck in a "NotStarted" state. A very basic test: [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") $SmoServer = New-Object Microsoft.SqlServer.Management.Smo.Server MySqlServer Start-Job -Name Test -ScriptBlock { param($SmoServer) $SmoServer.Databases.Name }

WIx - “Registry key not found” when trying to see if a value of SQL SMO exists

 ̄綄美尐妖づ 提交于 2020-07-09 05:57:52
问题 It's been a while since I've done any WiX, but just found out that a bit of an existing bootstrapper exe I wrote ages ago, isn't actually doing what I thought it was - doh !! I've seen other people with similar issues, but I still can't figure out why it's not working. I'm basically trying to determine if a particular version of SQL SMO is installed and am looking in the registry at this location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects

Using C# & SMO, how do I add a backup device to a SQL Server?

老子叫甜甜 提交于 2020-01-24 04:53:30
问题 I know how to use C# and SMO to create a file backup on a SQL Server: public void BackupDatabase(Microsoft.SqlServer.Management.Smo.Server server, string databaseName, string backupFilename, string backupName, string backupDescription) { Backup backup = new Backup(); backup.Devices.AddDevice(backupFilename, DeviceType.File); backup.Database = databaseName; backup.Action = BackupActionType.Database; backup.BackupSetDescription = backupDescription; backup.BackupSetName = backupName; backup

Using C# & SMO, how do I add a backup device to a SQL Server?

做~自己de王妃 提交于 2020-01-24 04:53:07
问题 I know how to use C# and SMO to create a file backup on a SQL Server: public void BackupDatabase(Microsoft.SqlServer.Management.Smo.Server server, string databaseName, string backupFilename, string backupName, string backupDescription) { Backup backup = new Backup(); backup.Devices.AddDevice(backupFilename, DeviceType.File); backup.Database = databaseName; backup.Action = BackupActionType.Database; backup.BackupSetDescription = backupDescription; backup.BackupSetName = backupName; backup

Getting list of server instances installed reliably

谁说胖子不能爱 提交于 2020-01-14 15:26:44
问题 I am using following code to get a list of server instances installed. Dim sqldatasourceenumerator1 As SqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance datatable1 = sqldatasourceenumerator1.GetDataSources() Sometimes this code works fine but most of the times it gets lost and system becomes unresponsive. Could anyone advise me some alternative code that is reliable in all conditions? Thanks 回答1: You could check the registry, for example you can try reading this registry key: HKEY

Getting list of server instances installed reliably

删除回忆录丶 提交于 2020-01-14 15:24:29
问题 I am using following code to get a list of server instances installed. Dim sqldatasourceenumerator1 As SqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance datatable1 = sqldatasourceenumerator1.GetDataSources() Sometimes this code works fine but most of the times it gets lost and system becomes unresponsive. Could anyone advise me some alternative code that is reliable in all conditions? Thanks 回答1: You could check the registry, for example you can try reading this registry key: HKEY

Getting list of server instances installed reliably

拜拜、爱过 提交于 2020-01-14 15:23:45
问题 I am using following code to get a list of server instances installed. Dim sqldatasourceenumerator1 As SqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance datatable1 = sqldatasourceenumerator1.GetDataSources() Sometimes this code works fine but most of the times it gets lost and system becomes unresponsive. Could anyone advise me some alternative code that is reliable in all conditions? Thanks 回答1: You could check the registry, for example you can try reading this registry key: HKEY