sql-server

Typical Kimball Star-schema Data Warehouse - Model Views Feasible? and How to Code Gen

I have a data warehouse containing typical star schemas, and a whole bunch of code which does stuff like this (obviously a lot bigger, but this is illustrative): SELECT cdim.x ,SUM(fact.y) AS y ,dim.z FROM fact INNER JOIN conformed_dim AS cdim ON cdim.cdim_dim_id = fact.cdim_dim_id INNER JOIN nonconformed_dim AS dim ON d...

Best Method to Spawn Process from SQL Server Trigger

How would I go about spawning a separate process using a SQL Server 05/08 trigger? Ideally, I would like to spawn the process and have SQL Server not wait on the process to finish execution. I need to pass a couple parameters from the insert that is triggering the process, but the executable would take care of the rest. ...

SQL NOT IN constraint and NULL values

This issue came up when I got different records counts for what I thought were identical queries one using a not in where constraint and the other a left join. The table in the not in constraint had one null value (bad data) which caused that query to return a count of 0 records. I sort of understand why but I could use some help fully g...

Sql Server 2000 - How can I find out what stored procedures are running currently?

I'd like to know what stored procedures are currently running to diagnose some performance problems. How can I find that out? ...

Optimistic vs. Pessimistic locking

I understand the differences between optimistic and pessimistic locking*. Now could someone explain to me when I would use either one in general? And does the answer to this question change depending on whether or not I'm using a stored procedure to perform the query? *But just to check, optimistic means "don't lock the table while re...

Sql server real datatype, what is the C# equivalent?

What is the C# equivalent to the sql server 2005 real type? ...

Profiling SQL Server and/or ASP.NET

How would one go about profiling a few queries that are being run from an ASP.NET application? There is some software where I work that runs extremely slow because of the database (I think). The tables have indexes but it still drags because it's working with so much data. How can I profile to see where I can make a few minor improvement...

How can I query the name of the current SQL Server database instance?

It is a bit of a "chicken or egg" kind of query, but can someone dreamup a query that can return the name of the current database in which the query executes? Believe me when I say I understand the paradox: why do you need to know the name of the database if you're already connected to execute the query? Auditing in a multi-database envi...

Setting up Rails to work with sqlserver

Ok I followed the steps for setting up ruby and rails on my Vista machine and I am having a problem connecting to the database. Contents of database.yml development: adapter: sqlserver database: APPS_SETUP Host: WindowsVT06\SQLEXPRESS Username: se Password: paswd Run rake db:migrate from myapp directory ---------- rake abo...

Last time a Stored Procedure was executed

On Sql Server 2000, is there a way to find out the date and time when a stored procedure was last executed? ...

Planning to use PostgreSQL with ASP.NET: bad idea?

Hi everyone! I'm currently planning the infrastructure for my future web project. I want to go the way Joel went with having one DB per client and now thinking which DB engine will be good for me. The best would be of course SQL Server, but I can't afford a full-blown version at this moment and I don't think SQL Server Express will be a...

How often do you update statistics in SQL Server 2000?

I'm wondering if updating statistics has helped you before and how did you know to update them? ...

SQL Server Provisioning Tool

Running under Server 2008, SQL Server 2005 SP2 has the option to "Add New Administrator" from the SQL Server 2005 Surface Ara Configuration. This launches the SQL Server 2005 User Provisioning Tool for Vista. You are then able to grant privileges such as Server SysAdmin role etc. When I do this the privileges are copied across and appea...

Workaround for Spring/Hibernate due to non-standard behaviour of UNIQUE constraint in MS SQL

There is a UNIQUE database constraint on an index which doesn't allow more than one record having identical columns. There is a piece of code, managed by Hibernate (v2.1.8), doing two DAO getHibernateTemplate().save( theObject ) calls which results two records entered into the table mentioned above. If this code is executed without ...

How to check if column exists in SQL Server table

I need to add a specific column if it does not exist. I have something like this, but it always returns false.: IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName' AND COLUMN_NAME = 'myColumnName') How can I check if a column exists on a table in SQL Server? ...

Most efficient way in SQL Server to get date from date+time?

In MS SQL 2000 and 2005, given a datetime such as '2008-09-25 12:34:56' what is the most efficient way to get a datetime containing only '2008-09-25'? Duplicated here. ...

Good database table design for storing localized versions of data

I'm trying to design some tables to store some data, which has to be converted to different languages later. Can anybody provide some "best practices" or guidelines for this? Thanks ...

.NET: SqlDataReader.Close or .Dispose results in Timeout Expired exception

When trying to call Close or Dispose on an SqlDataReader i get a timeout expired exception. If you have a DbConnection to SQL Server, you can reproduce it yourself with: String CRLF = "\r\n"; String sql = "SELECT * " + CRLF + "FROM (" + CRLF + " SELECT (a.Number * 256) + b.Number AS Number" + CRLF + " FROM master..spt_v...

Insert a fixed number of rows 2000 at a time in sql server

I want to insert say 50,000 records into sql server database 2000 at a time. How to accomplish this? ...

Visio Stencils for MS SQL Server

Does anyone have a good set of Visio Stencils for MS SQL Server? ...