sql-server-2008

Databases Synchronization – best practice

We have live and stand-by database servers. Both are SQL Server 2008 databases and hosted on Windows Server 2003. May I know the best practice that people follow to synchronize the 2 databases (live and stand-by) so that we could make sure the stand-by server up whenever the live server is down for any reason. It would be great if you...

SQL Server 2008: tinyint vs bit

I need to add a new column to an existing table at work, and I'm wondering whether to create it as a tinyint or bit datatype. Our company recently upgraded from SQL Server 2000 to 2008, and IIRC my boss said there were issues in SQL Server 2000 when attempting to use bits. I think he said they were related to indexes and/or grouping --...

What is the preferred way of executing SQL in a Custom SSIS task?

I'm writing a Custom SSIS task that, as one of it's functions, should execute a stored procedure on a database connection. I can't seem to find any information about how this is done. I'm using an ADO.NET Connection Manager to connect to the database and I wish to write my Task in C#. What is the preferred way of executing SQL in a Cu...

Why do I sometimes get an error in Reporting Services when I export a report containing .jpg images to MS Word

When you create a report using SQL Server Reporting Services 2008 (SP1), that uses .jpg images sometimes you get the following error when you export the report to word. Index was outside the bounds of the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace ...

Can I install Sql Server 2008 on the same machine where Sql Server 2005 already installed.

I have Sql Server 2005 Express installed on my computer, and I want to install Sql Server 2008 Express as well. What should I consider before doing this additional installation? thanks. bk ...

LINQ2SQL: If I make changes to DB, how to mirror them in DBML?

Hi, I am using LINQ2SQL in my current project. I have a quite a lot of tables ~30. When I create my DBML file I change some of the column names etc for readability. Recently if I made a change to the table in the underlying Database I just deleted and re-added the table in the DBML file, but this is getting tedious. How can I mimic ...

Table Size Efficiency

We're doing some normalization of our data because it's too modular in some respects. The thing is that the table is getting very wide, with 400 or so columns so far. I've seen that the maximum amount is 1024 but I'm interested in knowing about paging with large table structures. If we had say, 1000 columns, but some were quite large ...

Are single statement UPDATES atomic, regardless of the isolation level? (SQL Server 2005)

In an app, Users and Cases have a many-to-many relationship. Users pull their list of Cases often, Users can update a single case at a time (a 1-10 second operation, requiring more than one UPDATE). Under READCOMMITTED, any in-use Case would block all associated Users from pulling their list of Cases. Also, the most recent data is a h...

Use each row in one table by joining it to another table

I'd like a query that at its simplest will join 2 tables together with no other express relationship other than each row in what I will call the "pool" table will match to precisely 1 row in my other table. I don't care which row, I just want every row in my primary table to get a single row from the "pool" table and know that each row f...

what is the maximum data stored on sql server cluster ever?

What do you think is the maximum database size ever stored on sql server cluster? ...

Optimizing SQL 2008 full text query (CONTAINSTABLE)

I've got the following query that uses a full-text index to search for the TOP 5 products (from the RawProducts table) matching the query, in a given Shop (populated by the @ShopId variable). At the moment I'm calling this procedure over and over again for every ShopId (there are 27 Shops) - which is a bit slow. My question is - could ...

How can I execute a .sql from C#?

For some integration tests I want to connect to the database and run a .sql file that has the schema needed for the tests to actually run, including GO statements. How can I execute the .sql file? (or is this totally the wrong way to go?) I've found a post in the MSDN forum showing this code: using System.Data.SqlClient; using System.I...

SQL Server 2008 - boolean variable change query

I have the following query: DECLARE @IsStocked bit SELECT * FROM Products p WHERE p.LastSeen > GETDATE() - 30 This returns all Products that have been seen within the last 30 days. My question is, I would like the p.LastSeen > GETDATE() - 30 clause to only apply when @IsStocked = true. This is part of a larger query, and I'd like...

SQL Server 2008 - excluding rows

Hi, I have the following query DECLARE @ProductIdsToExclude nvarchar(max) SET @ProductIdsToExclude = '49506541-4CE2-40AC-812A-7AB262E6F0B0,49506541-4ce2-40ac-812a-7ab262e6f0b0' I'm then using this function to parse @ProductIdsToExclude to a temp table: CREATE TABLE #TempProductIdsToExclude (ProductId uniqueidentifie...

SQL Server 2008 - limiting query by FK

I have the following query, which performs a full-text search (CONTAINSTABLE) on the Products table, and returns 1 record. Each Product is referenced by the ShopProducts table (each ShopProduct represents a product in a shop and is has a foreign key to Products.ProductId. Each row in the ShopProducts table has a ShopId column. My quest...

Is there a way to filter a SQL Profiler trace?

I'm trying to troubleshoot this problem using SQL Profiler (SQL 2008) After a few days running the trace in production, finally the error happened again, and now i'm trying to diagnose the cause. The problem is that the trace has 400k rows, 99.9% of which are coming from "Report Server", which I don't even know why it's on, but it seems...

Is the NOLOCK (Sql Server hint) bad practice?

Hi folks, I'm in the business of making website and applicatins that are not mission critical -> eg. banking software, space flight, intensive care monitoring application, etc. You get the idea. So, with that massive disclaimer, is it bad using the NOLOCK hint in some Sql statement? A number of years ago, it was suggested by a fellow S...

Cascade on Delete or use Triggers?

Im going through a project I have taken over, and on the database side I have noticed that the previous programmers have written a bunch of triggers to delete child records. The thing is, these records already have a a foreign key relationship with the parent record I am deleting. The delete triggers are nothing but simple delete state...

Select from C# in sql server 2008 too slow in windows server 2003 :(

Hi I've a soft in C# connected it whith sql server 2008. There are some reports created by crystal report. When I execute my soft in windows XP and sql server is installed at the same windows it runs very fast it takes up to 3 seconds to select and fill report. But when I execute it in windows 2003 and sql server is installed in the sam...

Retrieving failing package and error message in SSIS

I want to make a general error handling package that should be called from my other packages when something goes wrong. In this error handling package I want to log what task failed and the reason for the failure. How can I retrieve this information? I'm using the Control Flow Failure precedence constraint to point out a Execute Package...