Questions tagged [smo]

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

The SMO is a collection of .NET objects for managing SQL Server. It was introduced in SQL Server 2005 as a replaement for the prior effort, DMO (Database Management Objects).

The SMO is installed when you install any version of SQL Server Management Studio (including the free SQL Express version) or as a separate download via the SQL Server Fature Pack.

Resource: Diagram of class hierarchy: http://msdn.microsoft.com/en-us/library/ms162209.aspx MSDN

40 questions
15
votes
5 answers

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 methods of finding these instances, but neither seem…
Elsimer
  • 365
  • 1
  • 4
  • 13
9
votes
2 answers

SMO, SSMS are slow for management of SQL Server in Docker when connecting to localhost

TL;DR: When connecting to my SQL Server Docker container via a name that resolves to the IPv6 loopback (::1), SMO calls are really slow. When using 127.0.0.1, they're fast. I am trying to learn how to use the Docker image…
NReilingh
  • 785
  • 2
  • 9
  • 27
7
votes
1 answer

Gathering Read Routing information using SMO is inaccurate in SQL Server 2016

I've been playing around with SMO to check out some properties recently, and have come across a problem when trying to gather information on the read-routing order in SQL Server 2016. With earlier versions the routing list was quite simple, the list…
Nic
  • 4,063
  • 1
  • 16
  • 22
7
votes
2 answers

Why can't C# SMO see extended properties on a column but Powershell SMO can?

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using…
Wayne E. Pfeffer
  • 395
  • 1
  • 3
  • 10
6
votes
1 answer

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 all referring tables so that we can continue to…
Iain Samuel McLean Elder
  • 2,408
  • 5
  • 26
  • 39
6
votes
1 answer

How to check Query Store settings on model database?

Query Store can be enabled on the model database and ensures that every new database has the same settings as the model database. The GUI option is missing But it can be enabled using TSQL ALTER DATABASE model SET QUERY_STORE = ON (OPERATION_MODE =…
Zikato
  • 5,619
  • 1
  • 17
  • 34
6
votes
4 answers

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 programmatically. I know this is possible using .NET and…
usr
  • 7,390
  • 5
  • 33
  • 58
6
votes
1 answer

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 on Technet/MSDN SQL Server library but thought it…
user507
6
votes
2 answers

Are cursors/While loops the only way to make administrative changes to multiple databases?

I specifically want a programmable way to change the recovery model of all the databases on a server, and i know this solution can be applied to all 'Alter Database' commands. While I know SMO in PowerShell can solve this problem very…
Luke Pafford
  • 311
  • 1
  • 11
5
votes
2 answers

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 System.Data.SqlClient.SqlConnection and want to populate a data set…
user507
5
votes
2 answers

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 more easily? I will be running this from a central…
user507
5
votes
2 answers

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 that will invoke the backup at different…
Ken Richards
  • 278
  • 3
  • 7
4
votes
1 answer

Cannot read property Collation.This property is not available on SQL Server 7.0

I'm not able to add administrator role in SQL Server 2008 R2. When I try to add new user it throws me the following error: Cannot read property Collation.This property is not available on SQL Server 7.0. (Microsoft.SqlServer.Smo).
Sheeja
4
votes
1 answer

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 files have always included the table definition…
4
votes
2 answers

Handle expired SQL login's passwords in SQL Server

Is it possible to change the password for a login with an expired password using SQL Server Management Objects (SMO) programming? Many times during working hours I got this message from a production server. I have a 'sa' level privilege in SQL…
Md Haidar Ali Khan
  • 6,523
  • 9
  • 40
  • 62
1
2 3