smo

Using cursors to read time series data from SQL Server using C#?

 ̄綄美尐妖づ 提交于 2019-12-07 07:16:49
问题 I have a large database (50 million rows) containing time series data. There is a clustered index on the [datetime] column which ensures that that the table is always sorted in chronological order. What is the most performant way to read the rows of the table out into a C# app, on a row-by-row basis? 回答1: You should try this and find out. I just did, and saw no performance issues. USE [master] GO /****** Object: Database [HugeDatabase] Script Date: 06/27/2011 13:27:50 ******/ CREATE DATABASE

Need reference code for SMO in C# SQL Server 2008

好久不见. 提交于 2019-12-06 16:54:22
I googled but cannot find proper simple code for using backup database full and restore the backup, using defaults by using C#. I am using C# Visual Studio 2008 and SQL Server 2008 R2 evalution but I guess SQL Server 2005 and C# will work too. The Microsoft site doesn't have code regarding it, it only show description of Microsoft.SqlServer.Management.Smo Namespace...... MSDN has a topic Getting Started in SMO that covers a lot of ground - there's also a topic called Programming Specific Tasks which shows how to do certain common tasks in C# with SMO. And there's a whole series of Getting

Using Smo.Backup to backup SQL Server database to string

孤者浪人 提交于 2019-12-06 13:29:36
I'm trying to make a little app that would help me making my server backup. That app would run on my home PC so the main goal is to be able to connect to the external server, backup the selected database, dump the backup content to a string or something so I could write it on my PC disk and not the server's disk. I did that which works to write on the server's disk, but I'd like to be able to write on my PC's disk the backup's result. private bool BackupDatabase() { try { // Filename string sFileName = string.Format("{0}\\{1}.bak", _sWhereToBackup, DatabaseName); // Connection string

How to generate sql scripts using SMO scripter

纵然是瞬间 提交于 2019-12-05 20:38:18
问题 My database has tables, views and all. And I need a way to generate SQL script for all the DDL in an automated manner. No need for data. There are FK constraints so table creation scripts should be ordered properly. Some views use another view, so view creation scripts also have to be ordered properly. Starting from a script presented on MSDN Blog, I got the following: function Generate-SqlScript { param( [string]$srvname, [string]$database, [string]$ScriptOutputFileName ) [System.Reflection

Good book to learn Server Management Objects (SMO) for C# and SQL Server 2008? [closed]

妖精的绣舞 提交于 2019-12-05 17:18:23
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Am familiar with TSQL and C#, and would like to read a good book/tutorial on how to use Server Management Objects (SMO) with C# and SQL Server 2008. Any recommendations? Not a book per se - but a few good online resources: Getting

How to test connection to a data source in SSAS using C#

元气小坏坏 提交于 2019-12-05 16:18:47
I have a database in Analysis Services on a remote server. This contains a data source for another database located on another remote server. I am trying to write a connectivity test using C# which will check the database connection between the two databases. I have been unable to do this using ADOMD.NET. I'm currently looking at using SMO to do this but I haven't had any luck so far. I would greatly appreciate any advice or suggestions. Update: After further research, I have come up with the below test (Please note that I intend to add more try..catch blocks and Assertions later). Also, this

Problem in creating User in SqlServer using smo

我与影子孤独终老i 提交于 2019-12-05 15:13:00
1) If there is already a login 'user1' then I create a user 'user1' for database 'db1' by calling CreateDatabaseUser function 2) Else, I create a login 'user1' with password 'password1' with default database as 'db1' (only after creating db1) using CreateServerLogin and then I create user 'user1' for 'db1' using CreateDatabaseUser Method (2) throws an exception at newUser.Create(); in CreateDatabaseUser saying, Microsoft.SqlServer.Management.Smo.FailedOperationException: Create failed for User 'user1'. ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred

Using cursors to read time series data from SQL Server using C#?

蹲街弑〆低调 提交于 2019-12-05 15:08:55
I have a large database (50 million rows) containing time series data. There is a clustered index on the [datetime] column which ensures that that the table is always sorted in chronological order. What is the most performant way to read the rows of the table out into a C# app, on a row-by-row basis? You should try this and find out. I just did, and saw no performance issues. USE [master] GO /****** Object: Database [HugeDatabase] Script Date: 06/27/2011 13:27:50 ******/ CREATE DATABASE [HugeDatabase] ON PRIMARY ( NAME = N'HugeDatabase', FILENAME = N'C:\Program Files\Microsoft SQL Server

How can I retrieve SQL Stored Procedure Parameter's with SMO more efficently?

淺唱寂寞╮ 提交于 2019-12-05 14:27:04
I'm attempting to retrieve the DefaultValue of all the parameters in a StoredProcedure. My application is build in C# .NET accessing a Microsoft SQL 2008 Database. I use the SqlCommandBuilder.DeriveParameters to get most of the parameter information rather efficiently however it does not return the "DefaultValue" of a parameter so I've resorted to SMO to get that particular property. Here's my current code : Server svr = new Server(new ServerConnection(new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))); StoredProcedure sp = svr.Databases[

Can't find Microsoft.SqlServer.ConnectionInfo.dll assembly file?

China☆狼群 提交于 2019-12-05 11:00:10
问题 I'm trying to dynamically get a databases Table structure using only C# code as follows: using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Smo; public class LoadStuff { ... public void LoadDatabase(string vDatabaseName) { using (var vSqlConnection = new SqlConnection(DatabaseConnectionString)) { var vConnection = new ServerConnection(vSqlConnection); var vServer = new Server(vConnection); var vDatabase = vServer.Databases[vDatabaseName]; var vTables = vDatabase