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
1 answer

How to enable/disable a Service Broker queue using SMO?

I am using SMO objects to access my database. I have service broker enabled on SQL Server. I was wondering if anyone knew how to enable/disable queue's through code (VB/C#). I've tried ServiceQueue.IsEnqueueEnabled but this only sets the the…
0
votes
2 answers

Can i install microsoft sql server 2012 system CLR types on windows XP SP3?

I want to install SharedManagementObjects for SQL server 2012 express on a windows xp sp3 machine that has SQL Server 2008 R2 Express edition but does not have any edition of SQL Server 2012. But one of the prerequisites for installing…
StackTrace
  • 9,190
  • 36
  • 114
  • 202
0
votes
1 answer

Collection of MS SQL Server trace log

I need to write a program which can collect SQL Server trace logs from C code. There seem to be a couple methods to do this: Using the most common SQL trace method where trace files are mapped to tables via stored procedures. This trace log can…
b0ti
  • 2,319
  • 1
  • 18
  • 18
0
votes
1 answer

Is there a way to get a WMI.Service from a Server?

What it says on the tin. Essentially, I want something like this (in powershell, but that's largely irrelevant): $server = new-object "Microsoft.SqlServer.Management.Smo.Server" "my\instance" $service = $server.somePropertyOrMethod if…
Ben Thul
  • 31,080
  • 4
  • 45
  • 68
0
votes
1 answer

When attaching database with SMO, the database is readonly

I'm just trying to detach a database and reattach it using a different pair of mdf/ldf files using code like this: Server server = GetMyServer(); server.AttachDatabase(myDatabaseName, new StringCollection { mdfFile, ldfFile },…
RobC
  • 1,303
  • 3
  • 15
  • 32
0
votes
2 answers

Using SMO in C# to backup SQL Server database

I'm developing a simple utility which is going to create a *.bak file from a SQL Server database. If database has a quite small size, less than 50 Mb, then there is no problem, it's working well. But potentially I'm going to work with big databases…
Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
0
votes
0 answers

Programmatically determine max size of SQL Server Express database

Is there a way to determine the max size of a SQL Server Express database using SMO? Or will I have to add code to say if express then if sql2005 then limit = 4gb else limit = 10gb else limit = unlimited end
Dustin Gamester
  • 792
  • 3
  • 8
  • 24
0
votes
2 answers

How to Script out a trigger attached to a table in SQL

I would like to use smo and powershell script to out a trigger that is attached to a table . I have found a way to script out the table with the trigger but this is not what,I also wont always know the name of the table the trigger is connected to…
justinf
  • 1,246
  • 2
  • 19
  • 39
0
votes
1 answer

SqlServer SMO Scripting.ScriptingError event handler not firing

I have a SQL Sever 2008 R2/64-bit database server for which I'm writing some fairly basic scripting utilities with the Sql Server Management Objects (SMO). My project is a 32-bit VS2010 executable written in C#. Most of the effort has been fairly…
David W
  • 10,062
  • 34
  • 60
0
votes
1 answer

Create a copy of partitioned tables using SMO

I'm trying to use SMO to replicate a copy of a partitioned table: using (var scope = new TransactionScope()) { var copiedtable = CreateTable(sourcetable); createColumns(sourcetable, copiedtable); CreateIndexes(sourcetable,…
Simon
  • 196
  • 1
  • 2
  • 10
0
votes
1 answer

Smo EnumAvailableSqlServers does not return any data for SQl server 2012 with .net4

Smo call EnumAvailableSqlServers was working with .net3. But with .net 4 on sql server 2012 it doesnt fetch any data. I am passing parameter as false, Let me know if i need to use another APi?
Nida Sahar
  • 698
  • 4
  • 13
  • 29
0
votes
1 answer

Error "ConnectAsUserName was not set" but I'm not even using that property

I'm using the Microsoft.SqlServer.Smo.dll version 9.0.1399.0 in my [NAnt] build process. I'm running on Windows Server 2008 R2. I'm connecting to BOTH Sql Server 2008 R2 (10.5) as well as Sql Server 2008 (10.0). I'm tweaking the deploy step of one…
ganders
  • 7,285
  • 17
  • 66
  • 114
0
votes
2 answers

Retrieving the number of results sets from a Sql server stored procedure from c#

Hi I am writing a T4 template to generate accessors for Sql server stored procedures. I have used a mixture of SMO and DeriveParameters method of CommandBuilder to get almost all of the information I need. I am however unable to find a way of…
0
votes
1 answer

How to restore database programatically from backup with multiple files

I have no problem with restoring database programatically (in C# using SMO) from backup containing one file. But when the backup contains multiple files (full and differential backups) I get the following error The log or differential backup…
drv
  • 125
  • 1
  • 10
0
votes
2 answers

Scripting Table with SMO, issue for troubleshooting performance

With SMO, I meet a big performance problem : I script all Database object (functions, users, roles, table...) and when I script all Database object except table, it take less than 2 minutes, but when i enable table scripting it take 2 hours? So, i…
Hassan Boutougha
  • 3,871
  • 1
  • 17
  • 17