sql-server-2005

Alternative to SQL BULK INSERT

I need to import the data form .csv file into the database table (MS SQL Server 2005). SQL BULK INSERT seems like a good option, but the problem is that my DB server is not on the same box as my WEB server. This question describes the same issue, however i don't have any control over my DB server, and can't share any folders on it. I ne...

Are there any performance implications of making cross database calls in SQL 2005?

Are there any performance implications of making cross database calls in SQL 2005? In other words is it better for performance to have a stored procedure and function run within the same database as where the data resides? ...

How to check if a temporary table is existing in Database.

Hi, I am actually dropping a temporary table in Database. I have to delete only if it exists in the Database. Please let me know how to check if a table exists in Data base. ...

Change collation on clustered index column in SQL 2005

I have a Database that was created with an incorrect collation. I changed the collation of the database, but this left the individual columns with the incorrect collation also. This causes me a problem. So, I wrote a script to loop through and change the collation of the individual columns and this basically worked, except for a few col...

Best way to do serializable updates to a table

I'm a long time Firebird user and it has a feature called Generators (I think Oracle also has it and it's called Sequences). I'm new to SQL Server and I need to simulate the same feature. I can't use an identity field to solve my problem. I need a named series of values, not a unique number for each row. My biggest concern was about mor...

Watching variables in SSIS during debug

I have a project in SSIS and I've added an Execute SQL Task which sends its result out to a variable. I wanted to confirm the value because I was worried that it would try to write it out as a resultset object rather than an actual integer (in this case I'm returning a COUNT). My first thought was just to run it in debug mode and add th...

SSIS Deployment Utility - specifying different folders in MSDB

I am deploying my SSIS packages to MSDB by configuring the deployment utility and creating the manifest file in Visual Studio (2005). In the Integration Services, I created a new folder to segregate my packages. Is there a way to specify this folder for my packages when creating the deployment utility? If not, how do I move packages in...

How can I return multiple rows as a single row in T-SQL?

A few months ago our vendor added a capability to our ticketing system which lets us add any number of custom fields to a ticket. I'd like to query these fields out along with the other call information for reporting purposes, but each extensible field is stored as a row in the database. So basically you have something like this: ext_...

SQL Server 2005 DB Mirroring Error

I'm getting the following error when trying to setup SQL Server 2005 DB Mirroring on my servers. I am running two Win2K3 servers with SQL 2005 on each with one of those running alongside a SQL 2000 Version. After restoring the database with NORecovery and configuring the endpoints, I run into the following error when I try to start the...

Contraint - unique or empty

There is a nvarchar column in a table that allows empty values. Once there is a none-empty value it must be uniqe. Is it possible to define this rule without a trigger? EDIT: http://decipherinfosys.wordpress.com/2007/11/30/multiple-null-values-in-a-unique-index-in-sql-serverdb2-luw/ is a nice workaround. The only issue I see is th...

Rollback complete database one hour

We had some problems this morning and need to rollback our database for about one hour. Is this possible and how is it done? It is a Microsoft SQL 2005 database. BR Larre ...

SQL Server 2005 64bit query blocking

Hi We are experiencing some difficulties with SQL Server performance and wanted some help. Our environment is: - Windows 2003 Enterprise x64 Edition R2 Intel E5450 Quad Core 3ghz Processor 16GB RAM SQL Server 2005 64bit Enterprise Edition (9.00.3282.00) Database compatibility is 8 (but tested on 9 as well) Hyperthreading is switched ...

How do I join all values from multiple rows into a single row?

Lets say I have the query: SELECT Foo FROM Bar Which returns Foo A B C What I really what is: Foo A,B,C So all of the values from all of the rows has been collapsed into a single row (the commas are optional). Is there a way to use a select statement to do this because I do not want to use cursors? ...

Database Properties "Mirroring" Page

I am having a problem with one database on my SQL Server 2005 production server. A number of databases are already set up for mirroring, however when I right click and go to properties in SSMS, on one particular database there is no "Mirroring" property page available. I have done the normal tasks, such as setting Full Recovery model, ...

Partial import of Sql server 2005 database for local developement

So at work, my team is using a central SQL server 2005 database server for integration testing and I want to move to testing on my local database. The only problem is that the central database is in excess of 10 Gb. I am interested in importing the data objects and a rows for each table to ensure I can be up and running. Can you guys ad...

A simple MDX question

Hi, I am new to MDX and I know that this must be a simple question but I haven't been able to find an answer. I am modeling a a questionnaire that has questions and answers. What I am trying to achieve is to find out the number of people who gave specific answers to questions., e.g. the number of males aged between 20-25 When I run t...

Is it possible to use query parameters to fill the IN keyword

Imagine a table with GUIDs as primary key. I would like to select a few of these rows based on their primary key. I would like to use a query like: SELECT * FROM mytable WHERE id IN ('firstguidhere','secondguidhere'); I am using ADO.NET to query the database, so I would like to use a parametrized query instead of dynamic sql, which wo...

Sql Server Object Organisation

OK I'm not sure if this is valid, however I have a bug bear with SQL Server, and that is that I cannot organise objects in to a group of objects. Imagine I'm working on a new section of work in a large database and I perhaps have 15 objects that I will be regularly using. What I want to do is sort of "Favourite" them in to a folder so t...

For autoincrement fields: MAX(ID) vs TOP 1 ID ORDER BY ID DESC

I want to find the highest AutoIncremented value from a field. (its not being fetched after an insert where I can use @@SCOPE_IDENTITY etc) Which of these two queries would run faster or gives better performance. Id is the primary key and autoincrement field for Table1. And this is for Sql Server 2005. SELECT MAX(Id) FROM Table1 SELEC...

Pivoting tables

Hi all, I have a table like this: serialnumber partnb id actual nominal 1 1 AGR 15,2176803 15,2 1 1 APR 5,8060656 5,8 1 1 DCI 61,9512259 62 1 43 AGR 15,4178727 15,4 1 43 APR 7,235779 7,2 1 43 DCI 52,0080535 52 2 2 AGR 15,2097009 15,2 2 2 APR 5,8009968 5,8 2 2 DCI 61,9582795 62 2 ...