sql-server-2005

Various Moving Annual Totals in an SSAS Cube

This is how I am creating my moving totals as columns in my cube: MATTY (Moving Annual Total This Year) SUM ( { [Time Period].[Month].CURRENTMEMBER.Lag(12) : [Time Period].[Month].CURRENTMEMBER }, [Measures].[MeasureColumnName]) MATLY (Moving Annual Total Last Year) SUM ( { [Time Period].[Month].CURRENTMEMBER.Lag(24) : [Time Period]...

SQL Server 2005 - Nested recursive query :(

I have a query that I need to execute that I do not know how to structure. I have a table called Employees. I have another table called Company. There is a third table called Files. As you can imagine, a Company has Employees, and Employees have Files. I need to list out all of the Employees in my database. The challenge is, I need to ...

Get all non-clustered indexes

Does anyone know of a good script to get all the non-clustered indexes for SQL Server 2005? ...

Question on schemas and security

I need to set some users up to be able to create stored procedures with READ access only. Also, in production they cannot have SELECT, only EXECUTE on the procs they created. In development they would have SELECT so they could create their procedures. I've set up a schema called Reports. The owner of that schema is a login - Report_A...

Return string of description given string of IDs (separated by commas)

Hi SQL experts, I have one table A that has a column C and a lookup table (lookup) that provides a description given an ID. Here the setup: table A with column C values: 1,2,3 2,3,4 table lookup: 1, 'This' 2, 'is' 3, 'tricky' 4, 'SQL' Provide a SQL (SQL Server 2005) statement that returns the following strings: Input: 1,2,3 Out...

FTS in sql 2005

Can somebody please, let me know that how do we find that full text search is enabled in SQL 2005. ...

Insert a Row Only if a Row does not Exist

I am building a hit counter. I have an article directory and tracking unique visitors. When a visitor comes i insert the article id and their IP address in the database. First I check to see if the ip exists for the article id, if the ip does not exist I make the insert. This is two queries -- is there a way to make this one query Also...

php against sql server 2005 is timing out

I'm running a php script from the command line against SQL server 2005 using the MS driver for PHP and getting time outs. The query takes about 2 minutes from SQL Server Management Studio and returns > 300,000 rows. There are multiple queries in the script and for each one I do a sqlsrv_connect(), execute the query and then sqlsrv_free_...

How to Ignore SQL Error? - C#

I am making an insert on a unique column and the system is returning an error saying I can't insert duplicate rows. How can I ignore this error in C#? Edit Without using try/catch See this question for why I want to ignore the error. ...

Can I pass a table as a parameter when executing a storedproc?

Hi all, Is it possible to pass a table (or table variable) as a parameter of a storedproc when executing the storedproc. If yes then how. I need an example. Please help. ...

changing default hierarchy of Cube dimension

Hi , I have created Dealer dimension in SSAS 2005 and it has 3 hierarchies. By default the hierarchy created first is the default hierarchy of the dimension. Is there any way to change the default hierarchy to another hierarchy. ...

Error while exporting from ms sql to access

I am trying to export the following data in the query from ms sql server to access, it says an error "Field wkid already exists in the table results" when i try to execute the same using sql query analyser, its not giving any error.i am getting the results in the grid Select a.wkid,a.stid,a.pfid,pf.pfname,a.modid,mm.md,a.catid, [sp],re...

Is it possible to run replication on a SQL 2005 DB which is a mirrored principal server?

We have a client that currently has a large busy database that they back up using database mirroring. As part of a reporting requirement we need to use some of the data stored in the database to run reports against but we cannot access the data directly. Is it possible for us to run transaction replication on that server to get our d...

Arrays in UserDefinedFunctions?

I created a User Defined Function with VB.NET and want to use that function in SQLServer. Everything seems to work fine. Now I want to use an array as parameter. Is it possible? Example of my test method (without parameters): Partial Public Class UserDefinedFunctions <Microsoft.SqlServer.Server.SqlFunction()> _ Public Shared ...

How to set username and password for particular days?

Using VB.NET and SQL Server 2005 In my software I am using login page with UserName and Password. Suppose I am setting a username and password work for 20 days. After 20 days, when I try to login in software, the software should not to allow to login. Is possible to make a SQL query or VB.NET code. Can any one provide a sample code o...

Atomic Upgrade Scripts

With my database upgrade scripts, I typically just have one long script that makes the necessary changes for that database version. However, if one statement fails halfway through the script, it leaves the database in an inconsistent state. How can I make the entire upgrade script one atomic operation? I've tried just wrapping all of ...

Changing a full-text indexed column within a transaction

I'm writing an SQL data updater to convert old text/ntext/image type columns into varchar/nvarchar/varbinary. The updaters are run within transactions when the system boots to update the database from an older version. I've gotten the SQL to work on its own, but a handful of the columns being changed were full-text indexed, which means I...

Getting Monthly Data Even If Empty

I'm trying to get a report built up from data mining our accounting software. We have a table that stores the balances of each account in a general ledger for a given period (which is 0-12, 0 being carry over from last year, 1-12 being the corresponding month), the amount, and other data I don't need. I'm trying unsuccessfully to get ...

Statistics update seems to be causing problems

Woke up this morning with a page that our cluster was down. It came back up right away. I found log error logs with entries about IO taking longer than 15 seconds. Our monitoring server had tried to ping the server and had a timeout error. I checked one of our monitoring tools to see what was going on at 4:30 in the morning. It seems to...

How to set an array value using sp_OASetProperty

I have a stored procedure that manipulates some data in an excel spreadsheet. I am importing data by creating a QueryTable object. I would like to set TextFileColumnDataTypes property for the object but I can't figure out how to pass in an array to the sp_OASetProperty routine. This is what my code looks like but obviously it doesn't wo...