smo

Find recent backup using SMO

Does anyone know how to find the most recent backup for a database using SMO? ...

SQL Server SMO complains of missing DLL

Ok, I've scoured the web, BOL, various forums and I'm no closer to an answer...hopefully you fine folks can lend a hand... We've got a dozen or so SQL Servers (some 2k, some 2005) on a network. I'm using SMO objects in a .NET application to get some standard information. My problem appears to boil down to a missing DLL - Microsoft.SqlSe...

Adding properties to T4 template - picking server, database, table

Folks, I'd like to create some T4 templates for generating class files (about 7 per table) from a database to support our in-house ORM (don't ask - long story and historical reasons.....) What I'd really love to do is have a property on my main TT template to visually pick server, database and table for which to create the files (somet...

Programmatically detect SQL Server Edition

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 version of SQL Server (e.g., SQL Server 2008 vs SQL Server 2005). Does anyone know how to get the actual product edition (e.g., enterprise, stan...

Running a SQL install script with SMO. Alternative solutions needed.

Hi folks, I've got a web application that uses Microsoft Sql Management Objects (SMO) dll's. I'm wondering how I go about redistributing the libraries for a remote machine. As I understand it, these come with SQL server or Sql express - which isn't on the remote (shared) webserver. Asking the host to install them, is probably out of t...

Doing SQL Server backups - FULL / DIfferential and how often?

Hi there, Can anyone let me know what is the best practice for doing sql server backups i.e. FULL, differential and partial differential I will doing this from code using SMO (c#) but anyway... is it best to do a FULL backup every 1 month and a differential every day?? Just looking for a bit of guidance really Any ideas? ...

SQL 2005 SMO - find referencing table

I need to change some primary keys from non-clustered to clustered but I can't drop the constraint because it is referenced from other foreign keys. How can I find the tables that reference a primary key in the parent table as part of a foreign relation without looping through all tables in the DB? I need to disable the constraints on t...

SQL Server SMO TransferData() keeps failing

I am using the TransferData method of the transfer class in SQL Server SMO. I have the call running on Windows XP, running SQL Server 2008 SP1, trying to transfer a table from SQL Server 2000 on another server to the XP machine. They both use the same SQL username and password. I have tested using the Import/Export Wizard and it ran fin...

Does SQL Server SMO require special permissions to be used?

I have SMO code which copies tables from one database to another. It runs fine in a desktop app. The same exact code put in a service, gives an error. The error is really obscure and doesn't hint about permissions. I was wondering if the SMO objects need any kind of security to be used. Security context? Windows credentials.. etc? I am ...

Converting System.types to SMO.DataTypes

I have a project that creates a table from a DataTable to a SQL table via SMO. The datatypes of the columns do not convert currently from System.Type to SMO.DataType. I can do this via a Case statement but I was hoping for a cleaner solution. Maybe something involving TypeDescriptor.GetConverter(targetDataType). This works between Sys...

Checking for and dropping an existing table via C# and SMO

I am trying to look for a SQL table by name and if it exists drop it. This all needs to be done in C# using SMO. To complicate it a bit more the table also has a schema other then "dbo". Ultimatly the table will be recreated via SMO (I have this working) but I have to make sure it is not there before I can recreate it. All of the exam...

how to using smo library in c++

Hi I am trying to list all the instances of sqlserver using c++ in vs2005. How to do this using smo library in c++? give me code example. Thanks in advance.. ...

How to find where my data files and log files stored using smo in c#

Hi Can any body plz tell me how to find the location where my data and log files stored using SMO in c# Thanks in Advance ...

finding datafiles path including datafile name using SMO

Hi i have did like foreach(LogFile lf in db.Databases) Console.WriteLine(lf.FileName) which displays the logfile path including extension.....My Problem is how to find the Datafiles exact path including extension..Give me the Guidance Any Help is Greatly Appreciated... Thanks in Advance. ...

How to identify and get the sqlserver data files filepath

I am afraid that i am unable to locate the absolute path of the SQL SERVER data files. I have tried to so do by doing the following. foreach( Database db in srv.Databases) string filepath=db.PrimaryFilepath; string name=db.Name; abspth=filepath+"//"+name+".mdf"; Like this i have workaround.But is there is any alter...

Remove Relational Index Options when Scripting Table Index in SQL Server 2005

Using the Microsoft.SqlServer.Management.Smo.Scripter object, I'm generating scripts for each of the tables in my database, including indexes/constraints. When it generates the script, however, it includes all the index options, even though they are the default values, e.g., CREATE TABLE [dbo].[AgeGroup]( [AgeGroupID] [int] NOT NUL...

Restoring a Differential Backup with an SMO Restore object

I am trying to restore a database by first restoring a full backup and then restoring a differential backup by using the Microsoft.SqlServer.Management.Smo.Restore class. The full backup is restored with the following code: Restore myFullRestore = new Restore(); myFullRestore.Database = "DatabaseName"; myFullRestore.Action = RestoreActi...

How to Get Corresponding datafile path if i pass datafile name

Hi How to get enumfiles method in DMO in SMO means if i pass the master datafil;es to a method then it wil return the corresponding datafile path and logfile path. is there is any such method in SMO ?? for ex:in DMo Enumfiles(master) then it wil return corr filepath . is such method in SMO Plz Help me.. ...

How to display the remote sql instances of a particular machine using SMO?

Hi i wnat to display the Remote machine SQL instances using SMO .How to do this one. Suppose i am using the machine machine 1 from this machine i want to display the remote machine(ex machine2) SQL instances using smo how to this ?? i am using SmoApplication.EnumerateSqlServers(true) this dispalys only the local instances. false disp...

How to connect to the remote machine using c# and getting sqlserver instances ??

Hi How can i connect to the remote machine and getting the local instances using smo or any thing. using smo i did it for local instances but i dont know the same for remote instances how to do this. (My idea is connecting to the rmote computer and call the EnumAvailableSqlServers(true)) Can u give me ideas to do this??? Thanks in...