sql-server

Stored procedure executing another stored procedure

When a Stored Procedure has a query inside to execute another Stored Procedure, does the calling Stored Procedure stop other Stored Procedure has finished executing? I guess I'm trying to get straight in my head whether it's like synchronous and asynchronous calls. ...

SQL Server Data Import Wizard using query from another server

I have a SQL Server 2005 instance, into which I am trying to import data from a SQL Server 2008 instance using an SQL Query. I am using the 2008 management studio, and the import/export data wizard. If I run the select query separately in the management studio, it correctly returns the ~88k rows that are required. The query returns the ...

From Server\Instance how do I determine service dependency?

Hi, I have an installer where the user enters the data source in the connection string (i.e. DataSource="machinename\instance"). Using C# given the machinename\instance string, I need know if the service name is MSSQLSERVER or MSSQL$SQLEXPRESS On one particular machine we have SQL Server 2005 (full) and SQL Express 2008 installed. T...

Why is my query so slow? (SQL Server 2008 full text search weirdness)

I have a table with a full-text indexed column MiddlePart. The table has around 600,000 rows. The following query is very fast (30 results, <1 second): select * from DomainName where contains (MiddlePart, '"antiques*"') OR freetext(MiddlePart, 'antiques') This query is also very fast (5 results, <1 second): select * from DomainNa...

Can I spread out a long running stored proc accross multiple CPU's?

[Also on SuperUser - http://superuser.com/questions/116600/can-i-spead-out-a-long-running-stored-proc-accross-multiple-cpus] I have a stored procedure in SQL server the gets, and decrypts a block of data. ( Credit cards in this case. ) Most of the time, the performance is tolerable, but there are a couple customers where the process is...

SQL optimization - execution plan changes based on constraint value - Why?

I've got a table ItemValue full of data on a SQL 2005 Server running in 2000 compatibility mode that looks something like (it's a User-Defined values table): ID ItemCode FieldID Value -- ---------- ------- ------ 1 abc123 1 D 2 abc123 2 287.23 4 xyz789 1 A 5 xyz78...

Copy a table from an SQL Server CE 3.5 database to another in Visual Studio 2008?

How can I copy a table from an SQL Server CE 3.5 database to another (also CE database) in Visual Studio 2008, using the design tools? Note: When right clicking on a table there is a "copy" command, but I couldn't find any "paste" command so far... ...

Index Seek vs. Clustered Index Scan - Why is the scan chosen?

The following query uses an index seek on an index on the LastModifiedTime column. SELECT CONVERT(varchar, a.ReadTime, 101) as ReadDate, a.SubID, a.PlantID, a.Unit as UnitID, a.SubAssembly FROM dbo.Accepts a WITH (NOLOCK) WHERE a.LastModifiedTime BETWEEN '3/3/2010' And '3/4/2010' AND a.SubAssembly = '400'...

SQL Server 2005: how to copy database from one server to another (manually/programmatically)

I am developing an ASP.NET-app which uses an SQL2005-DB - and from time to time I need to copy the db from the dev-environment to test or production - or vice-versa. With SQL2000, I had written some batches to do that, but haven't had the time yet to find out how to do that under 2005, and did it manually. In SQL Mgmnt Studio, I would de...

LEFT INNER JOIN vs. LEFT OUTER JOIN - Why does the OUTER take longer?

We have the query below. Using a LEFT OUTER join takes 9 seconds to execute. Changing the LEFT OUTER to an LEFT INNER reduces the execution time to 2 seconds, and the same number of rows are returned. Since the same number of rows from the dbo.Accepts table are being processed, regardless of the join type, why would the outer take 3x lon...

Exposing web based XML data via a SQL Server view

It seems that SQL Server has a fair amount of XML support. Mostly I've seen info regarding storing XML in SQL Server, querying XML data stored in SQL Server, and exposing data as XML. Is the following scenario an option: I'd like to expose xml data (it's an RSS view of workitems) from a web site via a SQL Server view. The motivation is...

How can SCOPE_IDENTITY return null when @@IDENTITY does not?

After executing an insert, I either select SCOPE_IDENTITY or @@IDENTITY. SCOPE_IDENTITY returns null but @@IDENTITY does not. I don't understand how this is possible. Can you think of a reason why this happens? ...

PHP SQL Server addslashes() how does this work for blank values?

I'm running into the problem of users being able to submit data with ' " and blank values. I think addslashes() will work but just wanted to know what it does for blank values? Example: User enters data like: Company Name: ABC's User can skip fields as well: Company URL: I want to know what addslashes() will add if they leave the f...

Check against a list of values in the database

Let's say TableA has a field called, FieldA. FieldA consists of a list of values with comma being the delimiter (i.e. 1,2,3,4). #MyVar# contains the value (a single value, NOT a list) I want to search for. Other than doing the followings, SELECT * FROM TableA WHERE FieldA LIKE '%,#MyVar#,%' OR FieldA LIKE '#MyVar#,%' OR Fi...

How can I cancel a database query in ASP.NET when the user's browser disconnects?

My ASP.NET (3.5) app allows users to run some complex queries that can take up to 4 minutes to return results. When I'm doing a long loops of code, I'll check Response.IsClientConnected() occasionally so I can end the page if the user closes their browser or hits the stop button. But when querying SQL Server, my .NET code is blocked at...

In SQL Server How can I use ROW_Number() with a subquery column?

Here's my query: DECLARE @StartRow INT DECLARE @PageSize INT SET @StartRow = 1 SET @PageSize = 5 SELECT ContractID,Property FROM ( SELECT c.ContractID, Property = ( SELECT TOP 1 p.Name FROM Com.Property p JOIN VContract.Contract2Property c2p ON c2p.PropertyID=p.PropertyID WHERE c2p.Contr...

What should the itemcount property in SQL Server match.

If the itemcount property does not exactly match the number of indexed rows is that a problem? Is there a numerical way I can ensure that I have a complete full-text-index? update: the property fulltextcatalogproperty('database','itemcount') does not equal the rowcount for the indexed tables. It is off by a few thousand. Does that indic...

Microsoft PHP SQL Server Connection Issues - How To Troubleshoot What Is Being Blocked.

I am connecting through Windows Authentication. I have two webservers on local system. IIS 6.0 on port 80, Apache 80:80; I have created a DSN and connected. I have written simple ASP/VBS Script and connected with this DSN. I've tried to use this DSN using odbc_connect in PHP and it failed. I then tried the connection as outlined he...

How do I trace SQL Server Failure Audit events?

I recently took over management of a Windows 2003 server. The application log is being filled up with messages like these: Event Type: Failure Audit Event Source: MSSQLSERVER Event Category: (4) Event ID: 18456 Date: 3/5/2010 Time: 4:00:30 PM User: N/A Computer: FAIROAKS1 Description: Login failed for user 'administrator'. [CLIENT: <...

ASP.NET web app deadlocking - think it's caused by SQL Server locking

Our client's web app restarts suddenly at random intervals. For each restart, we've found an entry like this in the Windows Event Log: Event Type: Warning Event Source: W3SVC-WP Event Category: None Event ID: 2262 Date: 2/21/2010 Time: 1:33:52 PM User: N/A Computer: LIQUID-NXCFZ9DJ Description: ISAPI 'c:\WINDOWS\Microsoft.NET\Framework...