How to find what is locking my tables

I have a SQL table that all of a sudden cannot return data unless I include “with (nolock)” on the end, which indicates some kind of lock left on my table. I’ve experimented a bit with dm_tran_locks to identify that there are in fact a number of locks on the table, but how do I […]

SQL Server – defining an XML type column with UTF-8 encoding

The default encoding for an XML type field defined in an SQL Server is UTF-16. I have no trouble inserting into that field with UTF-16 encoded XML streams. But if I tried to insert into the field with UTF-8 encoded XML stream, the insert attempt would receive the error response unable to switch encoding. QUESTION: […]

PHP PDO Connection to SQL Server with integrated security?

Can I connect to SQL Server 2008 using PDO and integrated security using the mssql driver? Currently doing something like this to connect normally: $db = new PDO(“mssql:host=host;dbname=db”, “user”, “pass”); This works fine using SQL Server authentication, but it is a pain having to create SQL server logins for loads of databases, so it would […]

Try to create a table from Select – SqL Server 2008 throws error

Hi I am trying to create a table using inner select statement… for example: CREATE TABLE JmxMonSer AS (SELECT * FROM services WHERE monitoring_enabled = 1); But keep getting error: Incorrect Syntax near keyword ‘AS’, Severity 15 please advice

SQL Server 2005 implementation of MySQL REPLACE INTO?

MySQL has this incredibly useful yet properitary REPLACE INTO SQL Command. Can this easily be emulated in SQL Server 2005? Starting a new Transaction, doing a Select() and then either UPDATE or INSERT and COMMIT is always a little bit of a pain, especially when doing it in the application and therefore always keeping 2 […]

Upload CSV file to SQL server

What is the best way to upload a large csv data file into SQL server using C# ? The file contains about 30,000 rows and 25 columns.

Should I get rid of clustered indexes on Guid columns

I am working on a database that usually uses GUIDs as primary keys. By default SQL Server places a clustered index on primary key columns. I understand that this is a silly idea for GUID columns, and that non-clustered indexes are better. What do you think – should I get rid of all the clustered […]

SQL Server 2008 Insert with WHILE LOOP

I have existing records like ID Hospital ID Email Description 1 15 Sample Description 2 15 Random Text I need to use a WHILE loop to insert rows with Hospital ID changing to a specific value or 32 in this case, while the others(not ID as it is auto generated) remaining constant. It […]

How do you open an SDF file (SQL Server Compact Edition)?

I have an SDF file and I would like to retrieve its schema and query it with some UI. How can I do this? I have no Visual Studio installed on the machine and I would like to install as little software as possible.

How can I create a SQL unique constraint based on 2 columns?

I have a Table like this one: |UserId | ContactID | ContactName ————————————— | 12456 | Ax759 | Joe Smith | 12456 | Ax760 | Mary Smith | 12458 | Ax739 | Carl Lewis | 12460 | Ax759 | Chuck Norris | 12460 | Bx759 | Bruce Lee I need to add a constraint to […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.