SMO stands for SQL Management Objects (and is technically called "Shared" Management Objecs by at least one installer).

learn more… | top users | synonyms

2
votes
3answers
93 views

What is the most effective way to discover all running instances of SQL Server using PowerShell?

I've been tasked with discovering all the instances of SQL Server that are running within our domain. In several cases there are multiple instances per server. I've seen two different PowerShell ...
0
votes
0answers
7 views

Set method to change StartMode property using SqlServer.Management.Smo.Wmi.Service

I'm trying to change SQL server Configuration manager settings using Microsoft.SqlServer.Management.Smo.Wmi.Service. Microsoft provided with a list of methods & properties here. I used the ...
3
votes
1answer
216 views

Why can't I script out CLR assemblies with SMO in Powershell?

I am creating a Powershell script to read all objects in a source database, script them and then re-create them in an empty destination DB (may be across different SQL Server versions). For the most ...
3
votes
2answers
1k views

Using SQL Server SMO with a Port number

In SSMS if you are connecting to SQL Server instance set to specific port other than 1433 you simply put ",port number" after the instance name. In the same regard if I am using ...
1
vote
1answer
230 views

Why SMO's Transfer tries to login into linked server when scripting?

Consider this code sample: var sourceDatabaseConnectionString = "Data Source=MyServer;Initial Catalog=MyDatabase;User Id=MyLogin;Password=MyPassword"; var serverConnection = ...
0
votes
1answer
970 views

What is the best practices to backup and restore full and partial database with SQL Server 2012 and C#?

How can I do the following with C#: Completely backup an existing database. Partially backup an existing database. Completely restore an existing database from a backup file. Partially restore an ...
1
vote
2answers
1k views

Shrinking log files with SMO

I know I can use the following t-SQL to shrink a log file: BACKUP LOG db1 TO DISK = '\\server\share\db1_log1.trn'; DBCC ShrinkFile([db1_log], 0); How do I do the same with SMO? I tried: $server = ...
5
votes
1answer
318 views

Why am I missing some output?

Archiving to avoid ID Exhaustion We are about to run out of IDs in one of the tables of our OLTP logging system. It's my job to find a way to 'archive' the existing row data in the full table and in ...
5
votes
2answers
602 views

SQL Server SMO and PowerShell formatting

I have probably been looking at this for too long to figure this out... What is the easiest way I could get this exported to a CSV format? Would it be better to dump this to a table in a database ...
3
votes
1answer
1k views

SMO v11 (SQL Server 2012) not scripting key definitions, indexes, and constraints

I have a .ps1 PowerShell script that runs on a Central Management Server. The script goes out to all databases in our environment, and scripts out all of of objects. For tables scripts, the output ...
5
votes
2answers
789 views

Can I Run Two Full Backups on SQL Server 2005 at the Same Time?

Running SQL Server Express 2005 here. We are creating several programs which run a backup on the database using Server Management Objects (SMO) mostly through C# (.NET). We have separate processes ...
5
votes
4answers
2k views

Script Contents of SQL Server Database From a Batch File

I want to be able to script the schema of a given database into a .sql file from the Windows command prompt. Basically, I want to execute the "Generate Scripts" feature of Management Studio ...
5
votes
1answer
285 views

SQL Server SMO Method “Discover()”

I think I just found the coolest thing every with SQL Server SMO and PowerShell. I was asked to get a script together to find the owner of every object in an instance of SQL Server. I found a script ...
0
votes
2answers
273 views

Is command BACKUP asynchronous operation

I got strange delays when backed up a group of databases (20 more) in one scope (TSQL) to the same file location. Is it possible that multiple backup operations are running at the same time? I have ...