sql-server

Forcing a query timeout in SQL Server

We have had an issue with a block of code that responds poorly in the face of slow databases (It craps the bed on a query timeout). We have created a patch, and are in the process of running it through regression. We can't get a timeout. I've opened a transaction from SQL Mgmt Studio and updated every row to lock them, but that doesn't ...

Problem with SQL Server "EXECUTE AS"

I've got the following setup: There is a SQL Server DB with several tables that have triggers set on them (that collect history data). These triggers are CLR stored procedures with EXECUTE AS 'HistoryUser'. The HistoryUser user is a simple user in the database without a login. It has enough permissions to read from all tables and write ...

Is there any way to undelete a SQL server database and stored procedures?

Is there any way to undelete a SQL server database and stored procedures? Edit: No I don't have a backup. That is the reason I need help ...

A Developers guide to SQL Server Analysis Services and OLAP

This post from SqlBatman describes a situation similar to my current client and, in reality, indicative of many companies that rely on tons of reports which have been shifted to over-night processing because of their performance impact. How do I get started using Analysis Services in general and OLAP Cubes in particular to help my clie...

Hierarchical Database Driven Menu in MVC

I use the code below as an HTMLHelper which gets data from the database and loops over it to display a menu. This is fairly straightforward as you can see however, what if you have a database table using the adjacent model of heirarchies eg/ID, ParentID, OrderID. Easy to see whats going on but recursion is needed to get this data out pr...

stored procedure structure

I've inherited a legacy system with lots (160+) of stored procedures. I'm looking for a way to create a diagram that would show which of the procedures are called by other procedures show which part of the C# code uses which stored procedures group the procedures by the parts of the system in which they are used Is there a tool that ...

What is a good XDOC (or C# equivalent) style of program/plug-in for SQL Server?

I'm looking for a way to properly comment my stored procedure code so that I can extract the information into useful documentation ala something like XDOC (or C# equivalent). Something that's preferably lightweight would be ideal. ...

Changing a record in a table (sql server) that has foreign keys?

Hi there, Does anyone know if there is a quicker way of editing a record that has foreign keys in a table (in sql server).. i will explain.. i have approx 5 tables that have there own ID but are linked together using a foreign key... Hence i needed to change the foreign key (the contract number in my case), but i had to copy each recor...

Using SSIS to build a database from a VS2005/2008 database project

How do I allow an SSIS package to consume a Visual Studio 2005 or 2008 Database project which houses the creation scripts for the tables and other objects (note: this is not Visual Studio Database Edition - just Pro with Business Intelligence)? The idea is to use this to recreate my test instance by building the schema from source safe...

How to export SQL Server 2005 query to CSV

I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the fields (except concatenating them to the field values, which is ugly). I guess I could do...

What makes a SQL statement sargable?

By definition (at least from what I've seen) sargable means that a query is capable of having the query engine optimize the execution plan that the query uses. I've tried looking up the answers, but there doesn't seem to be a lot on the subject matter. So the question is, what does or doesn't make an SQL query sargable? Any documentat...

Why do SQL Server Scalar-valued functions get slower?

Why do Scalar-valued functions seem to cause queries to run cumulatively slower the more times in succession that they are used? I have this table that was built with data purchased from a 3rd party. I've trimmed out some stuff to make this post shorter... but just so you get the idea of how things are setup. CREATE TABLE [dbo].[GIS_L...

advantages in specifying HASH JOIN over just doing a JOIN?

What are the advantages, if any, of explicitly doing a HASH JOIN over a regular JOIN (wherein SQL Server will decide the best JOIN strategy)? Eg: select pd.* from profiledata pd inner hash join profiledatavalue val on val.profiledataid=pd.id In the simplistic sample code above, I'm specifying the JOIN strategy, whereas if I leave off ...

SQL Server 2005 to MySQL connection

I want to be able to email a report daily from a glpi database in MySQL. I would like to create a SSIS job to pull data from MySQL. How do I do this? ...

java impersonation to connect to sql server using windows authentication

right now I have the following architecture built with classic asp and visual basic 6 I have a COM+ component developed in VB6 which connects to the dabatase. I set the DB conf thru an .udl file configured with integrated security. At the web server (IIS) I register the componente with the com+ manager, and configure it to be run under...

What is the use of replication in SQLSERVER2005

Hi can any body tell me what is use of replication in sqlserver2005. backup and replicaton looks same?what is diference b/w them ...

Is there a possibility to connect storm to a MS SQL Server database?

I'm using the ORM storm. The official documentation says, that it can connect to SQLite, PostgreSQL and MySQL. Has someone already written a database backend for the MS SQL Server or is it possible to make the server emulate MySQL or PostgreSQL? Update 1: I've found two bazaar branches: Storm MS SQL 2005 MSSQL-Support Does anyone...

Documenting a DB (sql server) with visio or something better?

Hi .. been reading a few bad reports about viso and documenting DBs ,... I just want something simple to document the DB and show all the keys and relationships... Is visio the right way to go? .. its a fairly small project and visio does carry a price tag... I am using vs 2008 and this has database diagrams integrated but i don't thi...

Why FOR Trigger does not run befor the action?

I am trying to write a trigger on a table to avoid insertion of two Names which are not flagged as IsDeleted. But the first part of selection contains the inserted one and so the condition is always true. I though that using FOR keyword causes the trigger to run before the INSERTION but in this case the inserted row is already in the tab...

How to unit test full text search in ASP.NET MVC

I've just started out using ASP.NET MVC and TDD. I've read that while unit testing you should focus on testing your code, not other systems, like the DB. However, what happens when essential functionality is residing in the DB? I've used the MVC Storefront series as an initial guide in how to set up my projects and patterns. As full tex...