sql-server-2005

Microsoft SQL Server 2005 Setup error

Hi am getting following error while setup Microsoft SQL Server 2005.why can you please anybody tell me? Thanks in advance Microsoft SQL Server 2005 Setup SQL Server 2005 Setup cannot continue because the installation package could not be opened. The installation package has a missing file, or you are running a 32-bit only Setup progra...

How to lay out my integration tests

I have a rather large set of integration tests developed in C#/NUnit. Currently it is one test fixture, one class. In [TestFixtureSetUp] I create a database from a script and populate it with test data, also from a script. My tests do not modify data, so they can run in any order or in parallel. My problem is that I have too many tests...

procedure to upload excel into sql server

Hallo All, Please help in determining the best procedure for the following problem. In a user interface, there is a provision to upload excel file. This is done by admin, once/twice in a day on a regular basis. The code that i have used to upload excel file into sql server. select * into #temp FROM OPENROWSET('Microsoft.Jet.OLEDB.4....

Most optimized way to get column totals in SQL Server 2005+

I am creating some reports for an application to be used by various states. The database has the potential to be very large. I would like to know which way is the best way to get column totals. Currently I have SQL similar to the following: SELECT count(case when prg.prefix_id = 1 then iss.id end) + count(case when prg.prefix_...

Importing images in SQL Server 2005

Dear All, I have another issue. I have in the SQL table Employees. This table has lot of details but I was missing images or photos. So i managed to take all pictures for all employees but I have the pictures in the folder. Each picture is named like an Employee_id which matches the record in the table. How do I import images into SQL ...

Can I optimize this sql Query?

Below is a sample query of what I am trying to do and it gets the job done but I feel like the sub queries are not the best way to go here. Any pointers? SELECT DISTINCT u.UserID, (SELECT COUNT(LoginID) FROM Logins WHERE Success = 1 AND UserID = u.UserID) AS Successful, (SELECT COUNT(LoginID) FROM Logins WHERE Success = ...

What is the difference in these two queries as getting two different result set?

I am getting different result set for these two queries and second result set seems to be correct. What is the difference in these queries. What type of inner join query second is? 1) FROM TABLE1 t1 INNER JOIN TABLE2 t2 ON t1.Id = t2.Id WHERE t1.StatusId = 12 2) FROM TABLE1 t1 INNER JOIN TABLE2 t2 ON t1.Id = t2.Id AND t1.Sta...

How can you tell what Tables are taking up the most space in a SQL Server 2005 Database?

How can you tell what Tables are taking up the most space in a SQL Server 2005 Database? I am sure there is some System Stored Procedure that shows this information. I have a TEST database that grew from 1tb to 23tb. We are currently doing a lot of client conversion testing in the database, which entails running the same conversion S...

checking existence of a row before doing a SELECT INTO (SQL Server)

Hi everyone, I have a SQL statement I'd like to amend. As it stands now I'm running a simple SELECT INTO but I'd like to modify it so only records that don't exist in the destination table (as determined by my criteria) are appended. Here's my initial statement: SELECT b.BallotID, m.MeetingDate INTO StagingTable FROM Ballot I...

Displaying partially hierarchical data with nested repeaters

I'm SO close, but so far. I've got two tables, one for publication details, the other for the categories adjacency list. I'm trying to display the full dataset with nested repeaters (unless there's a better way) and I'm building my DataSet as shown: string strSql = "SELECT category_id, parent_id, cat_name_en " + "FROM c...

How to Take Part of a String using One of the T-SQL Text Functions

I have the following snippet: CONVERT(varchar, FLOOR(ROUND((DATEDIFF(minute, shiftStart.timeEntered, shiftEnd.timeEntered) - DATEDIFF(minute, lunchStart.timeEntered, lunchEnd.timeEntered)) * 1.0 / 60, 2, 1))) + ':' + CONVERT(varchar, ROUND(ROUND(DATEDIFF(minute, shiftStart.timeEntered, shif...

How optimal is this function

I'm about to implement this function to calculate some numbers. CREATE FUNCTION [dbo].[funLookupFTE] (@PFID int) RETURNS VARCHAR(20) AS BEGIN DECLARE @NumberOfFTE AS VARCHAR(20) SET @NumberOfFTE = (SELECT SUM(CASE WHEN Hours <= 20 THEN 0.5 WHEN Hours > 20 THEN 1 END) AS FTECount FROM tblPractitioners ...

T-SQL Update Statment with ORDER BY

I am using SQL Server 2005. I would like to update fields like Order BY MatchId orders as below query. But updeted fields not order by MatchId. DECLARE @counter int SET @counter = 10008 UPDATE Matches SET @counter = MatchNumberCounter = @counter + 1 WHERE MatchId IN (SELECT TOP (232) MatchId FROM Matches WHERE LeagueStatueId =...

SQLServer join two tables

Hi guys, I've gotta question for you, I'm getting hard times trying to combine two tables, I can't manage to find the correct query. I have two tables: T1: 1column, Has X records T2: 1column, Has Y records Note: Y could never be greater than X but it often lesser than this one I want to join those tables in order to have a table with t...

Modify the sql query in asp.net?

I am using sql server 2005. In this query i want the log-in user detail should also display but it is not displaying . So please modify the query so that log-in user detail should also display with the help of session[userId].tostring(); Query written by me is: SELECT DISTINCT MUDMEMBER.PK_ID, MUDMEMBER.EMPLOYEE_ID, LKB.BANK_NAME, MUH...

SQL Server 2005: how to subtract 6 month

I have a date, suppose today date declare @d datetime set @d = '20101014' I need select @d - <six month> where is the real number of days that contains last six month, beginning from @d. ...

Easy SQL query But getting confused

I am facing a problem for writing an sql query which should be easy I guess but I am not able to concentrate on that query. Hence taking some help from this website. Problem: I have an table "Request" which has following columns - CreatedOn: When I create new request, the CreatedOn is filled up with current datetime LastModifiedOn: Wh...

Why did this trigger change speed my query up?

Hi, I've been trying to solve a slow trigger problem and now that I have through trial and error, I still don't know what the original problem was. The query I'm running is the following: UPDATE tblA SET X = NULL WHERE X IS NOT NULL AND Z = 0 It updates around 30k rows. And the part of the AFTER INSERT, UPDATE trigger on tblA caus...

T-SQL query help - select unique grouping?

My table has 3 columns: RecordId Value InsertDate Each RecordId has multiple entries in the table. In fact the table gets updated several times a day. How do I write a t-sql query to select all the latest rows (based on InsertDate) for each unique record? My t-sql skills are non-existent. Thanks in advance ...

SQL Server 2005 Maintenance Plan fails

I am getting an error on our Maintenance plan in sql server 2005 saying that the Setp1 of job cannot be run because the SSIS subsystem failted to load. The job has been suspended. How can I fix this and unsuspend the job so that I can run the plan? ...