sql-server-2008

Best way to deploy new index to very large table in SQL Server 2008

I have a database in production with one table that has grown extremely large (lots of accumulated data). To improve query performance I used the sql server optimizer which suggested a new index. So I made a copy of the production database to test against and it does improve performance, however my problem is that it took about 24 hou...

Instead Of Delete Trigger with FileStream

Why can't i use an Instead Of Delete Trigger on a table that has a varbinary filestream column? Is there a workaround for it? I want to update a field when a delete command is performed. Thanks ...

How can I use a containstable with a restriction on the data in the table it is searching?

I have a table which contains my ads that can be searched in sql-server-2008. See the following piece of code. is_searchable in the ad_search table is basically the flag for whether this ad should be included in the search. The three examples below produce unreasonable output in my mind: In the first example 1000 records are returned....

How to store the following SQL data optimally in SQL Server 2008

I am creating a page where people can post articles. When the user posts an article, it shows up on a list, like the related questions on stackoverflow (when you add a new question). It's fairly simple. My problem is that i have 2 types of users. 1) Unregistered private users. 2) A company. The unregistered users needs to type in their...

Why isn't SSMS smart when it comes to adding columns?

Whenever I want to add a column to a table it usually goes something like this: Fire up SQL Server Management Studio (SSMS) Select "Design" on the table I want to add the column to Add the new column to the table Save Get an error that SSMS can't save because it would need to drop the table (and it can't because the the table has forei...

Loading cache overloads database

When my site starts I open a second thread that loads lots of data into the cache. The web layer work as expected, but it leads to to much load on the database. Other queries are not served in reasonable time anymore. The DB is read only, so there are no locks involved. Is there a good way to tell my thread to take it easy? Something l...

SQL Server 2008 Full text search on a table with a composite primary key

Hi everyone! I am trying to put full text search working on SQL Server 2008, however the table i am trying to index is a table with a composite primary key, something like this: EXEC sp_fulltext_catalog 'My_Catalog', 'create' EXEC sp_fulltext_table 'Message', 'create', 'My_Catalog', 'PK__MESSAGES__C87C0C9C0EC32C7A' // PK__MESSAGES__C87...

XPath to check if all provided pairs of elements exist for an entry

I have the following XML stored in an XML field in a SQL Server 2008 database. <attributes> <attribute> <key>animal</key> <value>rat</value> </attribute> <attribute> <key>color</key> <value>black</value> </attribute> </attributes> I'm able to select all the entries from the table which have an 'animal' key with...

updating a column in a table only if after the update it won't be negative and identifying all updated rows

Hello all, I need some help with a SQL query. Here is what I need to do. I'm lost on a few aspects as outlined below. I've four relevant tables: Table A has the price per unit for all resources. I can look up the price using a resource id. Table B has the funds available to a given user. Table C has the resource production info...

How to Disable Publishing And Distribution?

I'm getting the following error while disabling publishing and distribution. Plz, tell me how to do disable publishing and distribution? SQL Server could not disable publishing and distribution on 'server'. An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) ...

How to replay a SQL Profiler trace on different database?

I've captured a trace (template: tsql_replay) on our production server for a specific database (filtered by database name). I'd like to replay on it on our test server, but of course the database id is different on the test server. So far, I've tried loading the trace file into a table and modifying the databaseid with an update query ...

Connection between J2me and Sql Server 2008

I want to connect my mobile application(J2me) with SQL Server 2008. Please help me. I'm new in j2me. I need any articles or examples about this connection. ...

Sql server stored procedure

I have to write a update stored procedure. I will be asking paramters for all the columns ( Except id). User won’t be sending all the paramaters all the times. He wants to send paramter value NULL so don’t update that column, the columns he wants to update there will be valid value. How do I Write a stored proc for this. Basically I will...

Advice on Change Tracking in Sql Server 2008

My client is looking for a way to do a full audit trails (full view of historical data on all tables) on the application. Other than using the old fashioned way of having table copies or storing field name, field value, modified by, modified on etc, I was looking at using Sql Server 2008 change tracking. Found a How-To article on msdn ...

SQL statistics system table

I have created a statistics in a table using SQL SERVER 2008 . In which system table this information is getting stored (Just like all the table info are stored in in sys.tables)...? ...

In 'LIKE' operator needs to select 'NULL'(DB) values

Hi all, This is a one typical Question asked my boss.. Q: how to select the value which are nulls in Database using LIKE operator.. I tried like below: select c.ClaimID from claim c where c.InjuredPartyFirstName like (''+coalesce(c.InjuredPartyFirstName,'')+'') But this also not working........ Please help some one Thanks in Ad...

How to do partial match with a SELECT IN query?

I'm not sure there is this exact situation in another question, so sorry if this a duplicate. I have a problem with the Category system I am using I have the following query (for example) SELECT DISTINCT COUNT(StockID) FROM tblStock WHERE CategoryCode IN ( SELECT CategoryCode FROM tblLookup WHERE CategoryID = 'EG') I need to do a pa...

Extract multiple numeric values from string with T-SQL

I have a column with data in a special “format”. Example: L100000 L50 L5 S10 S15L10 S20 S90 S10 S10L5 S10L40 S10L5 The value consists of an “S” and/or an “L”, each with a number following the letter. I need to write a query, which will return two columns, “S” and “L”, which will have only the coresponding numeric value following the l...

How to make a view column NOT NULL

I'm trying to create a view where I want a column to be only true or false. However, it seems that no matter what I do, SQL Server (2008) believes my bit column can somehow be null. I have a table called "Product" with the column "Status" which is INT, NULL. In a view, I want to return a row for each row in Product, with a BIT column se...

Management studio 2008 debugger does not support 2005

When I try to access a 2005 database in studio 2008 I receive the debugger does not support 2005 or earlier. This is a new install, as far as I understand. Is there something that I need to turn off to disable this? ...