sql-server

What is the scope of isolation in nested transactions in SQL Server?

Consider the following SQL: BEGIN TRAN SET TRANSACTION ISOLATION LEVEL READ COMMITTED INSERT Bands ( Name ) SELECT 'Depeche Mode' UNION SELECT 'Arcade Fire' -- I've indented the inner transaction to make it clearer. BEGIN TRAN SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED SELECT * FROM Bands COMM...

Perl ADO thinks printed output in stored procedure is an error!

First of all (in case this is important) I'm using ActiveState's Perl (v5.8.7 built for MSWin32-x86-multi-thread). I've just emerged from a three hour long debugging session, trying to find the source of an error. I found there was simply no error, but for some reason ADO's connection object was getting the Errors.Count increased with e...

Merge Primary Keys - Cascade Update

Is there a way to merge two primary keys into one and then cascade update all affected relationships? Here's the scenario: Customers (idCustomer int PK, Company varchar(50), etc) CustomerContacts (idCustomerContact int PK, idCustomer int FK, Name varchar(50), etc) CustomerNotes (idCustomerNote int PK, idCustomer int FK, Note Text, et...

SQL Server Stored Proc Argument Type Conversion

Suppose I have a bunch of varchar(6000) fields in a table and want to change those to text fields. What are the ramifications of the stored procedures whose arguments are of type varchar(6000). Does each stored procedure also need those argument data types changed? ...

SQL: How do I SELECT only the rows with a unique value on certain column?

Thanks a million everyone for everyone's response. Unfortunately, none of the solutions appear to be working on my end, and my guess is that the example I've provided is messed up. So let me try again. My table looks like this: contract project activity row1 1000 8000 10 row2 1000 8000 20 row3 1000 8001 10 row4 2000 9000 49 row5 200...

Are there benefits to a case sensitive database?

We have just 'migrated' an SQL Server 2005 database from DEVEL into TEST. Somehow during the migration process the DB was changed from case insensitive to sensitive - so most SQL queries broke spectacularly. What I would like to know, is - are there any clear benefits to having a case sensitive schema? NOTE: By this I mean table nam...

I need DTS to survive, which edition of SQL Server 2005 should I buy?

I heard about SSIS, a new replacement of the old DTS. I believe it has the same functionality which I used to perform. Now, like any other product from Microsoft, you have to mess with 10 different choices for a single package. I would like to get your opinion of which edition of SQL Server 2005 I should buy to ensure that I can replica...

Is it possible to see the CODE for sp_executesql? Is it TSQL??

Is it possible to see the CODE for sp_executesql? I would like to see the actual code. I could not find it in sql server management studio. ...

Is it possible to use Full Text Search (FTS) with LINQ?

I wonder if is possible to use FTS with LINQ using .NET Framework 3.5. I'm searching around the documentation that I didn't find anything useful yet. Does anyone have any experience on this? ...

Will SQL Server 2005 penalize me for using an nvarchar(50) as a primary key, instead of an integer?

I'm considering altering some tables to use nvarchar(50) as primary key instead of an int primary key. Using an int ID for a key really is irrelevant data, it's the string I'm interested in. What sort of performance hit will occur, or where do you research this? Other than cut and try that is. ...

Is it possible to write a stored procedure with dynamic parameters like sp_executesql?

Is it possible to write a stored procedure (in tsql or other variants) with dynamic parameters like sp_executesql? i.e. the number and type of parameters in not known in advance and should be built dynamically on client side. just the way you can pass any number of parameters with any type to sp_executesql. ...

SQL update from one Table to another based on a ID match

Hi All I realy hope someone can help me with this. I have a databse with Account Numbers and card Numbers that I match to a file to update any card numbers to account number so I only work with account numbers. I created a view linking the Table to the Account/Card db to return the Table ID and the related Account number. Now I need to ...

How do I set a SQL Server script's timeout from within the script?

I have a large script file (nearly 300MB, and feasibly bigger in the future) that I am trying to run. It has been suggested in the comments of Gulzar's answer to my question about it that I should change the script timeout to 0 (no timeout). What is the best way to set this timeout from within the script? At the moment I have all of t...

Is it possible to limit the maximum duration of queries in SQL Server 2000?

Specifically I'd like to detect when a query has been executing for over 5 minutes and then cause it to rollback, I could no doubt do this at an application level but am investigating if SQL Server has any built in mechanism to do this for me. Note, for clarification, I'm sadly still running SQL Server 2000. ...

SQL Server query execution plan shows wrong "actual row count" on an used index and performance is terrible slow

Today i stumbled upon an interesting performance problem with a stored procedure running on Sql Server 2005 SP2 in a db running on compatible level of 80 (SQL2000). The proc runs about 8 Minutes and the execution plan shows the usage of an index with an actual row count of 1.339.241.423 which is about factor 1000 higher than the "real"...

Building a view column out of separate columns

In our database, we have a system set up to keep track of applications. We have a bool column that indicates whether or not the application is approved. Then there's another column that indicates whether or not the application is denied. If neither column is true, then the application is considered to be pending. Is there any easy wa...

LINQ to SQL with RDBMS other than MS SQL Server

Is there any plans for Microsoft to support LINQ to SQL beyond MS SQL server? ...

Creating Default columns in SQL 2008 using Policy management (DMF)

Hi, Could someone tell me if its possible to add a policy to create default columns in a table schema using the SQL 2008 Policy management features So for example I may have a desire to have a Date column in all of my tables called CreateDate and no DBA could create a table without a column of type datetime with name "CreateDate" Is t...

SQL Server 2005 data file inconsistency (maybe 8 data files, maybe 5, who knows)

I have a SQL Server 2005 sp2 box where tempdb has either 8 data files or 5 data files dependingo n where you look. DBCC showfilestates and sys.database_files (both queried in tempdb) show 8 data files (tempdev - tempdev8), however when I query sys.master_files (in master db, which is also what the GUI uses), I only see 5 (tempdev, tempd...

Importing new database table

Where I'm at there is a main system that runs on a big AIX mainframe. To facility reporting and operations there is nightly dump from the mainframe into SQL Server, such that each of our 50-ish clients is in their own database with identical schemas. This dump takes about 7 hours to finish each night, and there's not really anything we...