sql-server-2008

Search and replace content in stored procedures

I realy dont know how I could have lifed without searching the text of stored procedures http://stackoverflow.com/questions/466130/can-you-search-sql-server-2005-stored-procedure-content. The next big think for me would be the ability to replace some text in a couple of stored procedures. Is there a way to do this? ...

How to catch SqlException caused by deadlock?

From a .NET 3.5 / C# app, I would like to catch SqlException but only if it is caused by deadlocks on a SQL Server 2008 instance. Typical error message is Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Yet, it does not seem to be a do...

Performance bottleneck - Linq to SQL or the database - how do I tell?

Hi, I am currently trying to ring more performance out of my reporting website which uses linq to sql and an sql server express 2008 database. I am finding that as I now approach a million rows in on of my more 'ugly' tables that performance is becoming a real issue, with one report in particular taking 3 minutes to generate. Essential...

Installing SQL Server 2008 on a development machine

I am setting up a new Windows 7 machine. I have installed VS 2008 Team System Developer / Database Ed. I have also installed SP1 and ran windows update. When I now try to install SQL Server on the machine it fails because I have a "Previous version" of visual studio. Anyone know why I am getting this error or how to fix it? EDIT I ...

T-SQL query to check number of existences

I have next approximate tables structure: accounts: ID INT, owner_id INT, currency_id TINYINT related to clients: ID INT and currency_types: ID TINYINT, name NVARCHAR(25) I need to write a stored procedure to check existence of accounts with specific currency and all others, i.e. client can have accounts in specific currency, so...

Upload / Download file from SQL Server 2005/2008 from WinForms C# app?

I'm using DocX to create .docx files. Instead of storing them on hard drive, Share or SharePoint i would prefer to store them inside SQL Database. So my questions are: How to write proper code to save file to that database? How to write proper code to retrive file to that database? What kind of datatype should i set for a table to hol...

sql server 2008 and 2005 on same machine?

I already have sql server 2008 installed and now need to install 2005 express as well. When I try this, the installation fails with: "An installation package for the product Microsoft SQL Server VSS Writer cannot be found" - any ideas anyone? ...

Does SQL Server have an equivalent to Oracle's PL/SQL Package?

I was wondering if SQL Server has an equivalent to Oracle PL/SQL Package? It is really nice to build your sprocs, functions, etc into a Package. ...

Failing to attach database

Hey! I am trying to attach a .mdf file in an asp.net 3.5 project to MS SQL Server 2008, so I will be able to open the database and edit it. I have tried to go to server management studio -> connect to server instance -> right-clicked databases and pressed attach -> press add in the "attach database" section. An explorer pops up but it is...

Meaning of Primary Key to Microsoft SQL Server 2008

What meaning does the concept of a primary key have to the database engine of SQL Server? I don't mean the clustered/nonclustered index created on the "ID" column, i mean the constraint object "primary key". Does it matter if it exists or not? Alternatives: alter table add primary key clustered alter table create clustered index Doe...

Materialized view or CDC?

I have a view on two tables (stored using SQL 2008) with millions of records. CREATE VIEW VwSalesAge AS SELECT Transactions.ID ,Transactions.Amount ,Customer.ID ,Customer.Name ,Customer.Age FROM Transactions INNER JOIN Customer ON Transactions.CustomerID=Custo...

How can I create valid connection string by using shared memory protocol to connect a named instance of sql server?

How can I create a valid connection string by using shared memory protocol to connect a named instance of sql server while the sql server browser is disabled? ...

How can I get a list of element names from an XML value in SQL Server

I have a table with an XML column in SQL Server 2k8. The following SQL retrieves some XML: SELECT TOP 1 my_xml_column FROM my_table Let's say it returns me the following XML <a> <b /> <c> <d /> <d /> <d /> </c> </a> What I would like to get is /a /a/b /a/c /a/c/d /a/e In other words, how can I get SQL Server to...

SQL Server-style Change Tracking (auditing) for Oracle

Having used SQL Server 2008 Change Tracking feature, I'm looking for a similar solution for Oracle. I'm mainly wondering if such a feature already exists in Oracle or if the standard solution is to use triggers and 'tracking' tables. I've googled, but I think 'change tracking' aren't the right keywords? ...

Message from SQL Server database to application when something changes in database

I have used triggers within a database .. like .. when record in table A is deleted then also delete the corresponding record in table B, C D .. e.c.t In SQL Server, is there a way to send message to application from database using triggers ... The scenario is ... If same application ( .exe ) is opened by 2 users and both use the sa...

How to choose the clustered index in SQL Server?

Usually the clustered index is created in SQL Server Management Studio by setting the primary key, however my recent question about PK <-> clustered index (http://stackoverflow.com/questions/2262998/meaning-of-primary-key-to-microsoft-sql-server-2008) has shown that it is not necessary to set PK and clustered index to be equal. So how s...

Fetch CSV value from XML data type in SQL Server 2008

I want to store the CSV to XML data type in the SQL Server table and has to return from that. What is the best way of doing this. I am facing some performance issues for 50,000 comma separated values. Note: I am using SQL Server 2008 ...

Can you add identity to existing column in sql server 2008?

In all my searching I see that you essentially have to copy the existing table to a new table to chance to identity column for pre-2008, does this apply to 2008 also? thanks. most concise solution I have found so far: CREATE TABLE Test ( id int identity(1,1), somecolumn varchar(10) ); INSERT INTO Test VALUES ('Hello'); ...

Script to generate default values for not columns with no defaults specified in SQL Server

I have a MySQL database that I am migrating to SQL Server. The application that references the database breaks when I run it against SQL Server because SQL Server does not offer the implicit defaults that MySQL offers. I wanted to see if there is a way to generate script that would force defaults on all NOT Null columns that do not have...

SQL Server 2008: Unable to remove a FileStream File and Filegroup

With SQL Server 2008 SP1, I've removed the only table that had a Filestream associated with it but each time I attempt to do the following: alter database ConsumerMarketingStore remove file CMS_JobInstanceFiles alter database ConsumerMarketingStore remove filegroup JobInstanceFiles I get the following exception: Msg 5042, Level 16, ...