sql-server-2005

What are common pitfalls when developing a new SQL database?

I know, I quite dislike the catch-all survey type questions, but I couldn't think of a better way to find out what I think I need to know. I'm very green in the world of database development, having only worked on a small number of projects that merely interacted with the database rather than having to actually create a new one from scra...

SQL Server Management Studio 2005 and Source Control

I have all my SQL stored in source control in the following structure Database Tables Stored Procs Views Static Data I'd like to tie my source control into SSMS, which seemingly supports source control, but SSMS wants to put all the scripts into one folder, which is a non-starter for me. Is it possible to get SSMS to ...

Multiple Select Statements using SQL Server 2005 "WITH" Statement

I am trying to use the "WITH" statement in SQL Server 2005. It seems to work fine if I do something like: WITH MyBigProducts AS (SELECT * FROM Products WHERE Size='Big') SELECT Name FROM MyBigProducts But it fails if I try to use multiple select statements like: WITH MyBigProducts AS (SELECT * FROM Products WHERE Size='Big') SELECT N...

How to group data from temporary table

Hi guys, I have created one temporary table in which corresponding to one fileid which is primary key, I am having 5 rows. I want to get the count as 5. What query do I have to write to get the count corresponding to each fileid? ...

SQL Server 2005 ,Pagin Query get all result count

HI, I have some Tables with a lot of records , for a report I have to join these tables. If I want to get all rows I get the Time out error, I used Paging query in SQL Server 2005 , and can get the result page by page. but I need to know the count of results or the count of pages of my query. on a paged query , if I use count() I got...

SQL Index Seek

I've got an odd thing going on with a query. I have a table with two bigints, StartNum and EndNum that defines number ranges. I have an index on these two columns. The query takes a given number and returns the range it falls into. The WHERE clause is where @Num >= StartNum and @Num <= EndNum. There's a big difference in the Profiler b...

SQL Server Performance Problem

Our primary database server is an 8 core box with 8GB of RAM. The CPU is a Xeon E7330 @ 2.4GHz. It runs Windows Server 2003 R2 (x64 edition) and SQL Server 2005 I wanted to do some testing so I set up SQL Server 2005 on another brand-new server which is an 8 core box with 4 GB of RAM. It has a Xeon X5460 @ 3.16GHz and runs Windows Serve...

SQL 2005: Disk space taken by dropped columns

I have a big table in SQL Server 2005 that's taking about 3.5 GB of space (according to sp_spaceused). It has 10 million records, and several indexes. I just dropped a bunch of columns from it, such that the record length got reduced to a half, and to my surprise it took zero time to do that. Obviously, sp_spaceused was still reporting ...

How can I make a primary key as AUTOINCREMENT

I have table in Database and the primry key is 'ID', Just I want to ask how can I make it AUTOINCREMENT I know that's esay Q, but I dont know how can I do it. thanks ...

Sql 2005 SSRS- users other than me cannot access report

I created a report in SQL BI studio, and in the sql server 2005 Configuration tools made all the setup. In IIS the directory security is Anonymous Access ticked. I can access the website, but no one else can. I changed the setting to Integrate Windows Authentication and then the people could connect but they had the username and password...

Getting nonsensical results from SQL query

Hi, I've encountered a very, very strange situation in my application. I say strange because the errors are intermitent and I cannot find out why they occur. I've pass a sqlcommand to the DB (Sql 2005) trying to get a bigint (column ID_Facultate) from a single table. The problem is that I've got a string (the name of some lecture) that...

Simulation of CONNECT BY PRIOR of ORACLE in SQL SERVER

I would like to get the functionality of CONNECT BY PRIOR of ORACLE in SQL SERVER 2000/2005/2008? Please help me ...

Row Col Transposition in SQL Server 2005/2000

In SQL Server 2005, I have a table say tbl_Info. There I have one column say Info. The values are as under Name1 Age1 Sex1 Name2 Age2 Sex2 ..... ..... ..... And the row values goes on like this. My question is how to make row col transposition. The desired output will be Name Age Sex Name1 Age1 Sex1 Name2 ...

How to use recursive table valued function in SQL SERVER 2005

I am making a split function in SQL Server 2005. I have already done it by using a while loop . But I am not happy with that. I want to do it using recursive function. I have already done it in C#. Now I am plotting the same in SQL SERVER 2005. But I am getting a compilation error. Here is my code ALTER FUNCTION [dbo].[fnSplit2] ( ...

Checking referential integrity rule violation before deletion

Before deleting a row from a table, is there any simple way to check that it would violate a referential integrity rule? I'd like to do this from a C# win form application (.Net 3.5) using SQL Server 2005. ...

sql server query running slow from java

I have a java program that runs a bunch of queries against an sql server database. The first of these, which queries against a view returns about 750k records. I can run the query via sql server management studio, and I get results in about 30 seconds. however, I kicked off the program to run last night. when I checked on it this mor...

Store and Retrieve .ZIP file in SQL SERVER 2005

How to store .zip file in SQL SERVER 2005 database programatically? And how to retrieve it back? If you think that storing a .zip file into a database is not an elegant way, please tell me the idea of making a better approach / standard practice for the same I am using C#, Asp.net and Sql Server 2005 Please send me the code. ...

SQL QURY PROBLEM

Suppose i have a table like this.. ColA ColB ColC A 100 1 A 200 2 A 300 3 B 100 1 B 200 2 C 300 1 I have to select COLA where 100=1 and 200=2 and 300=3 pls help ...

Difference between New_Id() & Rand() SQLSERVER2005

How newid() Function Work in Back Ground ? What is the difference between rand() and newid() ? Which is more efficient? Thanks in advance. ...

Why so many sp_resetconnections for C# connection pooling?

We have a web service coded in C# that makes many calls to MS SQL Server 2005 database. The code uses Using blocks combined with C#'s connection pooling. During a SQL trace, we saw many, many calls to "sp_resetconnection". Most of these are short < 0.5 sec, however sometimes we get calls lasting as much as 9 seconds. From what I've r...