sql-server-2008

Count for consecutive records

I have a table as follows > RowID SessionID EventID RequestedURL Date > 1 m2jqyc45g 1 Start 24/03/2010 19:52 > 2 m2jqyc45g 1 ProductPage 24/03/2010 19:52 > 3 m2jqyc45g 28 BuyNow 24/03/2010 19:52 > 4 tjmvb55dc4dg 1 ProductPage 24/03...

SQL Script to clear database tables.

I have a need to take backup of a SQL Server Db with tons of data in it and import into another environment for updating and testing. Since, i am not interested in the data, i just want to recreate the schema on my other server. There is an option called 'Generate Script', but is throwing errors running them on the target server. Curio...

Database schema last updated date.

How to find out the last date and timestamp of schema updation in SQL Server database. I could locate the database created and last back up date from properties. But, couldn't find the last schema updated date. Is there a way to find this out? ...

Excluding facts having unrelated dimensions

In my Analysis Service OLAP Cube I would like to exclude facts having unrelated dimensions, which during processing produce errors. I would also like to avoid making Named Queries in Data Source View (with specific WHERE conditions). Is there any way to do this at the level of a cube? What is the easiest way to accomplish this? (I am ...

Can't step into stored procedure on remote SQL Server 2008

I have a domain controller installed on virtual Windows Server 2008 x64. SQL Server 2008 Express x64 is running on Windows Server 2008 x64 and client on Windows 7 RTM x86. Both have joined the domain. I'm starting both Visual Studio 2008 and SQL Server Management Studio 2008 under domain admin user. This account is a member of group sy...

Find next date for certain record in SQL Server 2008

Hi In SQL Server 2008: I have two tables, dtlScheme and dtlRenewal, with a one to many relationship (one scheme can have many renewals). dtlRenewal has a unique key (dteEffectiveDate, dtlSchemeID). Now suppose I have the following data in dtlRenewal: dtlRenewalID dtlSchemeID dteEffectiveDate 1 1 1/1/2005 2 ...

How do I avoid a repetitive subquery JOIN in SQL?

Hi In SQL Server 2008: I have one table, and I want to do something along the following lines: SELECT T1.stuff, T2.morestuff from ( SELECT code, date1, date2 from Table ) as T1 INNER JOIN ( SELECT code, date1, date2 from Table ) as T2 ON T1.code = T2.code and T1.date1 = T2.date2 The two subqueries are exactly identical. Is there...

How to handle data concurrency in ASP.NET?

Hi! all I have an application, that is accessing by number of users at the same time. Those users, who are accessing the application getting the same id. Here what i am doing in the code is, when they are creating new user i am getting a max id from DB and increasing the value to 1. So that they are getting same ID. so that i am facin...

Syncing with and without Sql Server 2008 changes tracking

I've stuck with syncing a Sql server 2008 having changes tracking enabled with a 2005 one that doesn't have this mechanism. Would you please point me a right track, how can I handle this. Thank you, ...

What is the difference between cubes and the Unified Dimensional Model (if any)?

I'm currently researching SQL Server 2008 as a business intelligence solution, and currently looking at Analysis Services (and I'm pretty new to business intelligence as a whole...) I'm a bit confused by some of the terms in SSAS, particularly the conceptual differences between cubes and MS's Unified Dimensional Model. I believe tha...

Disable all non-clustered indexes

I select a number of non-clustered indexes from my database with the following: SELECT sys.objects.name tableName, sys.indexes.name indexName FROM sys.indexes JOIN sys.objects ON sys.indexes.object_id = sys.objects.object_id WHERE sys.indexes.type_desc = 'NONCLUSTERED' AND sys.objects.type_desc = 'USER_TABL...

trying to figure out how to send multiple file attachments with sp_send_dbmail

MSSQL 2008 Maybe i'm just looking in the wrong place. Here's the scenario: We have files stored in a varbinary(max) column. I'd like to select these as individual files, along with the names of the files stored nearby, as individual file attachments. can this be done? it's easy enough to send the results of a query as an attachment, ...

Compound IDENTITY column in SQL SERVER 2008

An Orders table has a CustomerId column and an OrderId column. For certain reasons it's important that an order's id is no longer than 2-bytes. There will be several million orders in total, which makes 2-bytes not enough for a global order id. A customer will have no more than several thousand orders making 2-bytes enough. The obviou...

sql 2008 metadata modified date

Is there a way to identify the timestamp when an object(table/view/stored proc...) was modified ? there's a refdate in sysobjects but it's always the same as crdate atleast in my case and i know that alter view/alter table/alter proc commands have been run many times post creation ...

sql server script generater stored proc

anyone know of such stored procs to generate scripts for tables/indexex/views/sp's etc. ...

Separating Strings from a CSV File in SSIS 2008

I have data which resembles the following: "D.STEIN","DS","01","ALTRES","TTTTTTFFTT" "D.STEIN","DS","01","APCASH","TTTTTTFFTT" "D.STEIN","DS","01","APINH","TTTTTTFFTT" "D.STEIN","DS","01","APINV","TTTTTTFFTT" "D.STEIN","DS","01","APMISC","TTTTTTFFTT" "D.STEIN","DS","01","APPCHK","TTTTTTFFTT" "D.STEIN","DS","01","APWLNK","TTTTTTFFTT" "D...

How to run a ssis package using a sql statement?

i'm using Sql Server 2008. There are options to run from command line. Is there a way to execute an ssis package using sql statement? -Vivek ...

Combine 2 apps into one DB?

I'm debating whether to use the same DB for both my blog and my wiki. Since both are open source, and both install the required tables which is a very small number of tables for both apps, I'm thinking about just using one database to represent both sets of tables. Is this common and safe to do? I am hesitant because I always create a...

How can I extend this SQL query to find the k nearest neighbors?

I have a database full of two-dimensional data - points on a map. Each record has a field of the geometry type. What I need to be able to do is pass a point to a stored procedure which returns the k nearest points (k would also be passed to the sproc, but that's easy). I've found a query at http://blogs.msdn.com/isaac/archive/2008/10/23/...

Using SSIS to import a CSV File.

I have data which resembles the following: "D.STEIN","DS","01","ALTRES","TTTTTTFFTT" "D.STEIN","DS","01","APCASH","TTTTTTFFTT" "D.STEIN","DS","01","APINH","TTTTTTFFTT" "D.STEIN","DS","01","APINV","TTTTTTFFTT" "D.STEIN","DS","01","APMISC","TTTTTTFFTT" "D.STEIN","DS","01","APPCHK","TTTTTTFFTT" "D.STEIN","DS","01","APWLNK","TTTTTTFF...