sql-server

Monitoring Cursors, what are some good queries/scripts to do this?

I need to provide management with proof that a group of existing stored procedures that use cursors are the cause of much of our performance issues. Can someone point me in the right direction to find scripts and queries to accomplish this, please? Such as, how to monitor and measure cursors, etc. Using SQL Server 2005. Thanks. ====...

SQL Server 2008: TOP 10 and distinct together

As the title says, I'm using SQL Server 2008. Apologies if this question is very basic. I've only been using SQL for a few days. Right now I have the following query: SELECT TOP 10 p.id, pl.nm, pl.val, pl.txt_val from dm.labs pl join mas_data.patients p on pl.id = p.id where pl.nm like '%LDL%' and val is not null What I wan...

SQL Server 2000 Delete Top (1000)

I have a large SQL Server database with a table at about 45 million records. I am archiving this table, and need to remove all entries greater than two years ago. I have the inserting into my archive table working fine, but I'm having issues with efficiency when deleting. My problem lies within the indexes currently on the table. I wou...

Problem when accessing another page while first page is processing a file

I have a web app which processes files and writes the data to a database. This process can take up to 2 minutes. Let's say this is done on ProcessFile.aspx. I wanted to ensure data integrity so I wrapped all the database processing in a TransactionScope. The problem occurs when I am processing a file and then try to access another page ...

.Net Error(The data area passed to a system call is too small)

Hi Am trying to execute ssis package using dtexec utility from c# app(Creating New Process, assign arguments to Info and finally Process.start(),while processing have come accross "The data area passed to a system call is too small" Error. System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) ** Note:it is fai...

dtexec processstartInfo

Hi What is maximum size of packagevariables for DTEXEC ProcessStartInfo while executing form C#(Process.start()) ...

Is latency or my VPN choking my Excel to SQL Server uploads?

I am uploading data from Excel to SQL Server using the following structure: Private Sub ado_upload() Dim objConnection As New ADODB.Connection Dim objCommand As New ADODB.Command Dim strSQL As String Dim strDSN As String Dim intCounter As Integer strDSN = "provider=SQLOLEDB;" _ & "server=<server>;" _ & ...

How to implement Publishing subscriber Replication topology in SQL?

How to implement Publishing subscriber Replication topology in SQL? ...

SQL Select top frequent records

Hi, I have the following table: Table +----+------+-------+ | ID | Name | Group | +----+------+-------+ | 0 | a | 1 | | 1 | a | 1 | | 2 | a | 2 | | 3 | a | 1 | | 4 | b | 1 | | 5 | b | 2 | | 6 | b | 1 | | 7 | c | 2 | | 8 | c | 2 | | 9 | c | 1 | +----+-----...

Covering indexes when extra columns uniquely determined by clustered index

Suppose I need to update myTab from luTab as follows update myTab set LookupVale = (select LookupValue from luTab B where B.idLookup = myTab.idLookup) luTab consists of 2 columns (idLookup(unique), LookupValue) Which is preferable : a unique clustered index on idLookup, or one on idLookup and...

multiple Database mirroring in 1 server instance

Hi, Is it possible to mirror 3 databases on 2 servers, ie. On server 1 database1, database2, database3 On server 2 mirrored database1, database2, database3 My admin claims due to endpoints its not possible to mirror 3 dbs from 1 server to another and one must use 3 servers each with 1 db... Any help appreciated, also links ...

Use variable with TOP in select statement in SQL Server without making it dynamic

declare @top int set @top = 5 select top @top * from tablename Is it possible? Or any idea for such a logic (i don't want to use dynamic query)? ...

Is there a way to have a SqlConnection that will write while an associated DataReader is open?

Or what's the recommended way to read and write at the same time? Having two connections open is the only way? This is on a plain Windows Forms C# (.NET 3.5) app using (SqlConnection conn = new SqlConnection(connStr)) { SqlCommand cmdRead = new SqlCommand("select stools from foo", conn); SqlDataReader rdr = cmdRead.ExecuteReader...

Is it possible to access the "Reporting Services\ReportManager\Web.config" file directly from a report?

I want to read an appSettings value from the c:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportManager\Web.config file and display it in a report. I added a reference to System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a and set field Value property to System.Web.Configuration.WebConfigura...

Pausing an SQL server script?

Hi, I'm trying to develop a script that I will be able to run on an SQL server 2008 [Express] database. The database contains about 10-15 tables that are being updated with different values / new fields etc. However, it's not a fully automated process and at points in the upgrade, it would be great to pause execution of the script, put...

How do i get the return value coming a database with just using return?

I need to get the value returned from a stored procedure in my Sql Server db.a This store procedure using a return statement to return a value back to the app. I need to retrieve this value in C#. How do i get this value? Note: I know i can use ExecuteScalar while using "select ..." in the sp to retrieve this value. I also know i can...

Populate DataGridView from a Stored Procedure

Using SQL Server 2008 I created a Stored Procedure called MyStoreProc and it runs fine from the Management Tools. In VB.Net 2008 I created a new dataset and a new TableAdaptor. In this table adapter I created a new Query called FillByGrid and selected the Stored Procedure. Previewed data and it previewed correctly. On a form I create...

SQL Profiler (SQL Server 2000), how to filter only my activities?

We have a big system with several hundred concurrent users so sql profiler gives a bit too much information without appropriate filters. I'd like to see what SQL commands are run under my account and my account only. With account I mean the username I use to log in to the system. These user names are stored in a regular database table an...

SQL select where there is only one date

Currently this query: SELECT InvoiceNumber, CustomerCode, Amount, InvoiceDate FROM Invoice Returns: aaa, 111, 5, 07/12/2009 bbb, 111, 5, 07/11/2009 ccc, 222, 5, 07/12/2009 However, I want to write: Where date = '07/12/2009', but I only want to return the results where there the customer has only one invoice... So Custo...

SQL Server VARCHAR(2) join performance vs. INT

Hi I have a table of q-grams (2 letter strings). I need to join another table to this on the CHAR(2) field. Would it be faster to convert these 2-grams into a number (e.g. aa=1, ab=2, ac=3) and convert the fields in both this table and the referencing table to an INT and join using an INT rather? Kind regards Peter ...