Questions tagged [smo]

SQL Server Management Objects (SMO) are .NET objects for management of Microsoft SQL Server. The namespace is "Microsoft.SqlServer.Management.Smo".

The Microsoft.SqlServer.Management.Smo namespace contains classes that represent the core SQL Server Database Engine objects. These include instances, databases, tables, stored procedures, and views.

The Microsoft.SqlServer.Management.Smo namespace contains the instance object classes that represent SQL Server Database Engine objects and some utility classes that represent specific tasks, such as scripting. When a connection to the instance of the SQL Server Database Engine has been established by using a Server object variable, objects on the instance can be accessed by using the SMO instance objects. For example, you can use the Database object to access databases on the connected instance of SQL Server Database Engine. All the instance classes are related to the Server class in the object hierarchy. Utility classes exist outside of the Server class object hierarchy and represent specific tasks, such as backup or scripting.

Most of the classes Microsoft.SqlServer.Management.Smo namespace resides in the Microsoft.SqlServer.Smo.dll and Microsoft.SqlServer.SmoExtended.dll files. Additionally, some of the enumeration classes are in the Microsoft.SqlServer.SqlEnum.dll and Microsoft.SqlServer.SmoEnum.dll assembly files. You will have to import all four files to access all of the classes in the Microsoft.SqlServer.Management.Smo namespace.

src=http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.aspx

810 questions
0
votes
2 answers

Want to manage SQL Server dynamically in c#

I want to manage SQL Server dynamically, that is through code I wan to scan SQL Server for available databases than I want to create new database, access older database, alter it, and insert data into database depending upon table schema what is…
abrar
  • 69
  • 1
  • 2
  • 4
0
votes
1 answer

Can I change the format of DATA scripted when scripting using SMO?

I would like to use SMO to generate a set of insert statements to copy data between environments. I have this working, but for some reason, datetime fields are formated as hex values that are casted to datetime. This makes the scripts hard to read…
Mike Schall
  • 5,829
  • 4
  • 41
  • 47
0
votes
2 answers

How do I script procedures when generating a script with the SMO scripter?

I am trying to write a Powershell script to generate a SQL script that creates the stored procedures in my database. Here is what I have: [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO')| out-null Function to-array…
0
votes
1 answer

Can we use SMO to take backup of database located at hosting server?

I followed the examples from http://msdn.microsoft.com/en-us/magazine/cc163409.aspx I am creating a utility that creates backup of databases (local or remote). I was able to create backup of databases located at my local server. But when I do so for…
Brij
  • 11,731
  • 22
  • 78
  • 116
0
votes
1 answer

Using SMO to restore a database from a .bak file

I tried a few solutions and below is the most straight forward one but I get the error below Logical file 'RestoredProcessMananger' is not part of database 'RestoredProcessMananger'. Use RESTORE FILELISTONLY to list the logical file names. RESTORE…
punkouter
  • 5,170
  • 15
  • 71
  • 116
0
votes
1 answer

IronPython stack trace cites a line in "except" block

I'm working on an IronPython (v2.7.3) module that connects to a given SQL Server database on a remote machine, and uses SMO to generate scripts for all of that DB's objects. My 'real' module has the code to generate a script for every defined…
JDM
  • 1,709
  • 3
  • 25
  • 48
0
votes
1 answer

Can't restore database from backup file

Based on this article I made a small WPF application to backup/restore a database. Code: using System.Windows; using Microsoft.SqlServer.Management.Smo; namespace DBManager { /// /// Interaction logic for MainWindow.xaml ///…
user2665411
0
votes
1 answer

Minimum privileges to read SQL Jobs using SQL SMO

I wrote an application to use SQL SMO to find all SQL Servers, databases, jobs and job outcomes. This application is executed through a scheduled task using a local service account. This service account is local to the application server only and is…
Gus Cavalcanti
  • 10,527
  • 23
  • 71
  • 104
0
votes
1 answer

File access using microsoft.sqlserver.smo.dll?

I'm using a C# application to Backup and Restore DBs on a remote server using the microsoft.sqlserver.smo.dll. Testing with my local machine, I can browse backup files to select the backup to use. Can this be done through code for the remote SQL…
Rick C.
  • 23
  • 3
0
votes
2 answers

Difference between using SMO and SQL queries (through SqlConnection) when building a SQL Server table

I don't really understand the difference between using one or other when creating a table in my SQL Server database. Is one safer or faster than the other when building a table?
Bob Bobalot
  • 23
  • 1
  • 8
0
votes
1 answer

check instance of sql server is running

How to check a particular instance of sql server is running or not which is installed in a network pc(not in local pc) by using vb.net. I can try to open a connection and check for timeout and find that connection failed.But i don't want it to do…
IT researcher
  • 3,274
  • 17
  • 79
  • 143
0
votes
1 answer

I need C++ API similar to fn_get_audit_file procedure in Microsoft SQL Server 2008 R2

I want to programmatically read audit trail files(.sqlaudit) logged in SQL Server 2008 R2. I wish they are be able to be viewed without using queries of SQL Server but with functions such as C++ API. I want to implement an application program…
user1804694
  • 121
  • 1
  • 5
0
votes
1 answer

SQL Server Database Roles via SMO

I am trying to add new roles to a SQL 2005 database via the SMO assemblies. The Roles.Add method just does not seem to add the new role. I have my user account set as securityadmin and sysadmin. Below is the code extract that I am trying to use to…
user204885
0
votes
1 answer

BackupDevice.PhysicalLocation does not add to specified location

Using C# and SMO, when I create backups they are being copied to the default backup location used by SQL Server (C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\Backup), instead of the physical location that I specify in code: …
DevDave
  • 6,700
  • 12
  • 65
  • 99
0
votes
1 answer

failed to retrieve data for this request - listing SQL Servers with SMO

DataTable dataTable = SmoApplication.EnumAvailableSqlServers(false); comboBox1.ValueMember = "Name"; comboBox1.DataSource = dataTable; i am trying to populate a combobox control with a list of SQL Servers available on the company network with…
StackTrace
  • 9,190
  • 36
  • 114
  • 202