smo Questions

1

We recently switched from Visual Studio 2019 to 2022 and upgraded our C# projects from .NET Framework 4.5.2 to .NET 6.0 using the upgrade assistant. The upgrades were successful, though we've encou...
Kerry asked 17/8, 2022 at 19:45

3

Solved

I have a bak file that has in it a back up of a database . I want to restore this database to a new location and I need to retrieve the database name from this file any idea how to do so ? I need...
Totten asked 14/11, 2010 at 9:4

4

Solved

I have the following code which works: foreach ($db in $svr.Databases | where-object { $_.name -eq "testDB" -or $_.name -eq "master" -or $_.name -eq "model" -or $_.name -eq "msdb" } ) { w...
Vamoose asked 24/8, 2011 at 16:59

9

Solved

Any pointers on how I can programmatically get exactly the identical stored procedure source from SQL Server 2005, as when I right-click on that stored procedure in SQL Server Management Studio and...
Percival asked 21/1, 2009 at 23:24

11

Solved

I need to use Server class which is stored in Microsoft.SqlServer.Smo.dll I don't see this assembly in usual References dialog. I have found it at C:/Program Files/Microsoft SQL Server/100/SDK/Asse...
Foresheet asked 23/6, 2011 at 11:39

7

Solved

I am trying to create a empty database in SQL server using powershell and SMO but cannot seem to find a way of doing it. Is this possible? Connection script for sql server: [System.Reflection.Ass...
Doublebank asked 8/11, 2011 at 10:13

7

Solved

I run my Winforms app using SQLServer assemblies Microsoft.SqlServer.ConnectionInfo (13.100.0.0) Microsoft.SqlServer.SMO(13.100.0.0) On the same machine SSMS 2016(Aug) is installed. And here SQL 2...
Twill asked 13/8, 2016 at 14:25

2

Solved

How do you make SMO release it's connections? I have this code: public static class SqlServerConnectionFactory { public static Server GetSmoServer() { using (var c = new SqlConnection(Configur...
Crichton asked 25/8, 2010 at 14:2

4

Solved

I have been working with SQL Server for a couple of years. I have heard about SMO but I don't know anything about it. What are the benefits of using it? Should I learn and start using SMO in my SQL...
Mincing asked 25/11, 2010 at 19:5

5

Solved

As the title says my intention is to find all tables participating in either INSERT/UPDATE/DELETE statements and produce a structured format. So far this is what I've come up with - void Main() { ...
Halfhardy asked 21/8, 2018 at 6:59

1

The SqlCommand class has a Cancel method that, according to the documentation, allows one to cancel a command. I'm looking for an equivalent method for commands executed through the smo Server cla...
Wildawildcat asked 16/3, 2015 at 18:35

3

Solved

I have SQL Server 2012 Developer installed on my machine. I also have the SQL Server 2014 management objects installed, too, which is probably the source of the problem. I'm writing a module to au...
Ellipticity asked 16/10, 2014 at 9:23

3

Solved

I'm writing T4 templates to generate CRUD stored procs etc I am looping through the columns of a table using SMO: For Each column As Column In table.Columns WriteLine("@" & column.Name &...
Centaurus asked 16/2, 2010 at 15:56

1

Solved

I use SMO to fill a SQL Compact database with the data of a SQL server database. Here is the code I actually use: foreach(Table l_tblCurrent in l_dbDatabase.Tables) { if(l_tblCurrent.IsSystemObj...
Evadnee asked 12/2, 2016 at 8:40

2

This is my problem, I have a restore function in C# guided by this answers: SMO: restoring to a different DB But when the program tries to execute this code db.SetOnline(); it throws an exceptio...
Garboil asked 24/8, 2016 at 16:26

1

I have an integration test that creates a database of type Microsoft.SqlServer.Management.Smo.Database: var defaultConnectionConnectionString = ConfigurationManager.ConnectionStrings["DefaultConne...
Claudicant asked 14/8, 2017 at 17:15

4

Solved

I'm creating a database using SQL Server Management Objects. I wrote the following method to generate a database: public static void CreateClientDatabase(string serverName, string databaseName) {...
Grayish asked 15/2, 2012 at 16:22

5

Solved

I'm using C# with SMO and attempting to detect what edition of SQL Server (e.g., enterprise, standard) I'm connecting to. I know how to get the version information, but that only tells me what vers...
Bemis asked 2/3, 2009 at 15:10

3

I have program that generates DDL scripts for a Microsoft SQL Server database using SQL Server Management Objects (SMO). However, depending on the server and database, I receive inconsistent output...
Gavan asked 21/10, 2014 at 5:55

1

Solved

I'm generating sql database script using c# code. following code works fine for create table but when I try to use scriptOptions.ScriptData = true; it is throwing following exception. An unhand...
Cominform asked 3/5, 2016 at 11:34

1

Solved

I am doing a C# project by VS2013 which is using smo object. I installed Install-Package Microsoft.SqlServer.Scripting Install-Package Microsoft.SqlServer.SqlEnum.dll by Nuget and included us...
Catchpenny asked 25/4, 2016 at 5:54

3

Solved

Is there a way to fix an orphaned user in a SQL 2005/2008 database using SQL SMO? You can find orphaned users relatively easily by enumerating through the users and looking for an empty User.Login...
Blader asked 10/9, 2009 at 19:3

5

Solved

I am trying to return the physical file path of a database's mdf/ldf files. I have tried using the following code: Server srv = new Server(connection); Database database = new Database(srv, dbNam...
Amazonite asked 23/1, 2009 at 20:59

5

Solved

I am using the Microsoft.SqlServer.Management.Smo classes to script out SQL scripts for stored procedures, tables, views etc. I am doing this for putting them in source control. Instead of the CR...
Heuer asked 1/7, 2010 at 16:51

5

Solved

What's the best method to check if SQL server exists or not? I'm trying Microsoft.SqlServer.Management.Smo.Server.PingSqlServerVersion() and it works fine if server exists and available. But it ...
Gorrono asked 15/7, 2010 at 15:25

© 2022 - 2024 — McMap. All rights reserved.