sql-server

Will a database generated from SQL Server Express work with the main version of SQL ?

I want to create a SQL Server Express database on my local machine and then upload it to a website that will be using the full SQL Server software - can I do this ? ...

Is recursion good in SQL Server?

I have a table in SQL server that has the normal tree structure of Item_ID, Item_ParentID. Suppose I want to iterate and get all CHILDREN of a particular Item_ID (at any level). Recursion seems an intuitive candidate for this problem and I can write an SQL Server function to do this. Will this affect performance if my table has many m...

Browsing SQL Server

Are there any tools for just browsing SQL Server? I ask because sometimes SSMS is a little heavy weight when I just want to look through the database and find one record, and SQLCMD doesn't really seem like a good choice when browsing through a lot of different records or a lot of large records. ...

Random record from a database table (T-SQL)

Is there a succinct way to retrieve a random record from a sql server table? I would like to randomize my unit test data, so am looking for a simple way to select a random id from a table. In English, the select would be "Select one id from the table where the id is a random number between the lowest id in the table and the highest i...

Recommended placement of tempdb and log for SQL Server OLTP database(s)

Suppose the following configuration: Drive D ... Data, Drive E .... TempDB, Drive F ... Log. and suppose all drives are on separate spindles with respective drive controllers. Concerning performance; is the above configuration optimal, decent, or not advisable? With budgetary constraints in mind, can any of these DB's share the save dr...

How to create a unique index on a NULL column?

I am using SQL Server 2005. I want to constrain the values in a column to be unique, while allowing NULLS. My current solution involves a unique index on a view like so: CREATE VIEW vw_unq WITH SCHEMABINDING AS SELECT Column1 FROM MyTable WHERE Column1 IS NOT NULL CREATE UNIQUE CLUSTERED INDEX unq_idx ON vw_unq (Column...

Teach an M.B.A. the intricacies of Microsoft SQL Server (and how's it different from MySQL?)

I haven't had to interact w/MSSQL much in my development career, though I've spent many an hour working with MySQL. An M.B.A. friend of mine is starting a job where she needs to gain functional knowledge of MSSQL Server, and I'd really like to help. What are the differences between MSSQL and MySQL? How would you recommend a non-techni...

How do you get output parameters from a stored procedure in Python?

I've googled around a bit, but maybe I didn't put the correct magik incantation into the search box. Does anyone know how to get output parameters from a stored procedure in Python? I'm using pymssql to call a stored procedure, and I'm not sure of the correct syntax to get the output parameter back. I don't think I can use any other db...

Give DROP PROCEDURE a parameter

I'm using SqlServer for the first time, and in every single one of our create procedure scripts there is a block of code like below to remove the procedure if it already exists: IF EXISTS (SELECT * FROM information_schema.routines WHERE routine_name = 'SomeProcedureName' AND routine_type = 'PROCEDURE' B...

Renaming Tables SQL Server, cascading that change through PK and FK's

I want to find a sql command or something that can do this where I have a table named tblFoo and I want to name it tblFooBar. However, I want the primary key to also be change, for example, currently it is: CONSTRAINT [PK_tblFoo] PRIMARY KEY CLUSTERED And I want a name change to change it to: CONSTRAINT [PK_tblFooBar] PRIMARY KEY CLU...

How do I profile a SQL CLR application?

I have a SQL CLR function in SQL Server 2005. I want to profile this function to make sure there are no memory leaks. Any recommendations on how to determine if my function is behaving properly? ...

MS SQL Concurrency problem, excess Locks

In my enviroment i have a database on ms sql 2000 that is being hit by hundreads of users at any time. Also the are lots of intense reports using reporting services 2005 hitting the same database. The problem we are getting is when there are lots of reports runnig at the same time and people using the database concurrent with the reports...

NT AUTHORITY\NETWORK SERVICE issue when deploying on remote server SQL 2005

I am getting a very non specific error when trying to connect to SQL server on remote server. I feel like I have made all the correct settings, allow TCP/IP, restarted the service, added rights to NT AUTHORITY\NETWORK SERVICE and other related users for the database. I can get to the aspx page, but as soon as I hit submit on the login I ...

How do I load and save an image from an SQL Server database using GDI+ and C++?

I need specifically to load a JPG image that was saved as a blob. GDI+ makes it very easy to retrieve images from files but not from databases... ...

What is an efficient way to check the precision and scale of a numeric value?

I'm writing a routine that validates data before inserting it into a database, and one of the steps is to see if numeric values fit the precision and scale of a Numeric(x,y) SQL-Server type. I have the precision and scale from SQL-Server already, but what's the most efficient way in C# to get the precision and scale of a CLR value, or ...

How to save a PDF file Using NHibernate and SQL Server 2005

I'm developing a webapp where the user is given the chance to upload his resume in pdf format. I'm using NHibernate as a data mapper and MS SQL SERVER 2005. I want to be able to save the .pdf file to a given table... any ideas? Thank you very much! ...

Performance of large EAV/open schema systems on SQL Server

Has anyone implemented a very large EAV or open schema style database in SQL Server? I'm wondering if there are performance issues with this and how you were able to overcome those obstacles. ...

Tool to compare sql server tables

Looking for a free tool to compare two sql server tables (both data and schema). Sorry, cannot afford any solutions from Red Gate. No Sql queries please. It would be great if the tool can script the differences found. I also went through some older posts. The closest I have seen is SQLDBDiff but I would love to try more options. ...

Is there a good way to do a SQL "InsertOrUpdate"?

I have some data records that may or may not exist already in my database. Right now when I want to update these records, I have to keep track of whether I got them from the DB, or created them from scratch, so that I know whether to make an INSERT or UPDATE query. I could query the database just before writing to find out if the recor...

Records not replicated when inserted by custom replication stored procedure.

I've just recently setup a custom replication for my subscriber database, as described in another post here. Basically, when the publisher pushes a new record to the subscribers, the stored procedure will also insert a replicated time into an extra column in the table, and insert a new record to a log table. My problem occurs when tryin...