sql-server-2005

SQL Server 2005: When clicking "Add" database I keep getting 'verify that the path or file exists'

When I right click on "databases" in Sql Server 2005 Management Studio and then > Attach... > Add I get the following error: C:\Documents and Settings\Administrator\My Documents\SQL Server Management Studio\ Projects\Path\To\MDF\And\LDF\Files\ cannot access the specified path or file on the server. Verify that you have ...

How to write a CASE WHEN statement with multiple DATEDIFF variables

I need to calculate the difference between two dates (facility_start_date, facility_end_date) for a report in Reporting Services in SQL 2005. If the facility_end_date is null then it needs to use the report parameter @EndDate in the calculation. However if the facility_end_date is greater than the parameter @EndDate, then it also needs t...

Improve SQL Server 2005 Query Performance

I have a course search engine and when I try to do a search, it takes too long to show search results. You can try to do a search here http://76.12.87.164/cpd/testperformance.cfm At that page you can also see the database tables and indexes, if any. I'm not using Stored Procedures - the queries are inline using Coldfusion. I think I...

Can I use PowerShell with SQL Server 2005?

Hi guys, I know SQL Server 2008 has exposed some features to PowerShell as snapins. Now I want to know whether I can use PowerShell with SQL Server 2005? I guess the answer is NO, right? Thanks. ...

remote sql server backup in local drive

hi,i wan to backup remote server in local machine ...

Combining multiple condition in single case statement in Sql Server

According to the following description i have to frame a case ...End statement in Sql server ,help me to frame a complex case..End statement to fulfil the following condition. if PAT_ENT.SCR_DT is not null and PAT_ENTRY.ELIGIBILITY is null then display display 'Favor' if PAT_ENT.SCR_DT is not null and PAT_ENTRY.EL is equal to No, displ...

Modifying SQL XML сolumn

I have an XML column in one of my table. For example I have an Employee table with following fields: Name (varhcar) | Address (XML) The Address field is having values like <Address> <Street></Street> <City></City> </Address> I have some n number of rows already in the table. Now I want to insert a new node - Country to all the rows...

Dynamic order by without using dynamic sql ?

I have the following stored procedure which can be sorted ascending and descending on TemplateName,CreatedOn and UploadedBy. The following SP when runs doesnot sort records.if i replace 2,3,4 by columnname, i got an error message "Conversion failed when converting the nvarchar value 'Test Template' to data type int.".Please suggest how t...

Obtaining the SQL Server 2005 Report Builder XSD

I've managed to obtain the report definition schema for SQL Server 2005, but cannot find the xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" schema anywhere. Is it part of the 2005 install buried somewhere? The reason I ask is because I've recently started writing RDL files for SQL Reporting Services. I'd lik...

Adding tables to sql server result in Domain\user.name.tablename

Our app uses migratordotnet to modify the backing SQL Server 2005 database. This works great 99% of the time but we are running into an issue. We have a client that is using and Active Directory group for sql server login and when new tables are added it creates them as Domain\login.table_name. What permissions are needed to be given ...

Using a RegEx in a SQL Query

Hey Everyone, Here's the situation I'm in: We have a field in our database that contains a 3 digit number, surrounded by some text. This number is actually a PK in another table, and I need to extract this out so I can implement a proper FK relationship. Here's an example of what would currently reside in the column: Some Text Goes ...

Is AWE in SQL 2005 Ent needed on 2003 32-bit w/ 24GB?

I have a WS 2003 32-bit system running SQL Server 2005 Enterprise with 24GB of RAM. The /PAE switch is enabled. Can SQL now use the 24GB or does AWE need to be enabled? ...

Need a set based solution to group rows

I need to group a set of rows based on the Category column, and also limit the combined rows based on the SUM(Number) column to be less than or equal to the @Limit value. For each distinct Category column I need to identify "buckets" that are <=@limit. If the SUM(Number) of all the rows for a Category column are <=@Limit then there w...

Using FOR XML AUTO against a synonym

We've just switched to synonyms for linked server stuff, and noticed that our FOR XML output is no longer correct. When returning XML results from a view, we could alias the view and that would be assigned as the element name. With synonyms, however, it seems to ignore the alias? We're still mostly on SQL 2005 - this bug doesn't seem ...

NullPointerException with CallableStatement.getResultSet()

Hello, I have a stored proc in SQL Server 2005, which looks like the following (simplified) CREATE PROCEDURE FOO @PARAMS AS BEGIN -- STEP 1: POPULATE tmp_table DECLARE @tmp_table TABLE (...) INSERT INTO @tmp_table SELECT * FROM BAR -- STEP 2: USE @tmp_table FOR FINAL SELECT SELECT abc, pqr FROM BAZ JOIN @tmp_table...

Split table and insert with identity link

Hi.. I have 3 tables similar to the sctructure below CREATE TABLE [dbo].[EmpBasic]( [EmpID] [int] IDENTITY(1,1) NOT NULL Primary Key, [Name] [varchar](50), [Address] [varchar](50) ) CREATE TABLE [dbo].[EmpProject]( [EmpID] [int] NOT NULL primary key, // referencing column with EmpBasic ...

how to list out all triggers in a particular table OR database?

how can I list out all triggers on a table? ...

TSQL, How to get smalldatetime's time between two smalldatetime's times ?

I have Table with two smalldatetime columns, where one is startTime and other one is endTime. I need to select all values from table which between times of both columns compared to getdate()' time. I'm using SQL-Server 2005. example startTime endTime value1 2/2/01 16:00 2/2/01 18:00 1 2/2/01 21:00 2/2/01 22:00 2 2/2/01 05:...

how to create before update trigger in sql server 2005

Is there anyway where I can create a trigger which will execute before the update/delete takes place( and then the actual update/delete takes place)? and how can I drop a trigger from a table? ...

Is it possible to execute stored procedure through a Linked server

Is it posible to execute Oracle 10g stored procedure on a sql 2005 Linked Server. ...