sql-server-2005

login failed connecting to SQL Server with AttachDbFilename and User Instance

I am developing ASP.NET 2.0 application using SQL Express 2005. I have attached my database with the application. The Connection string: <add name="WCMIRConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;\App_Data\WCMIR.mdf&quot;;Integrated Security=True;Trusted_...

calculating "Max Draw Down" in SQL

edit: it's worth reviewing the comments section of the first answer to get a clearer idea of the problem. edit: I'm using SQLServer 2005 something similar to this was posted before but I don't think enough information was given by the poster to truly explain what max draw down is. All my definitions of max draw down come from (the firs...

Help me select RDBMS for a standalone app. Few Concerns.

My app. is in C# 3.5 and MySQL 5.1. It is a Windows based standalone application. It is running successfully since last two years except few issues and that too were later found out to be MySQL bugs. The bug disturbed the real-time reports as it store the same timestamp in two rows. I don't know whether MySQL fixed it or not so I want t...

sql code/ logic

i have a self referencing table called project that has a master detail relationship between parent projects, and sub-projects, sub-sub-projects... one of the fields is releaseId and i need to make sure that the parent projects release id is the same for all its subs... table fields are projectId, parentProjectId, releaseId anyone hav...

finding local maximums and local minimums in SQL

In order to find the max draw down of a stock price versus time graph, you first have to find all local maximums (peaks) and local minimums (valleys) for a given set of prices and days. How would you do this in SQL Server 2005? edit: There is a brute force way of doing this with cursors: compare the high of the first day to the high of...

SQL Server stored procedure statements using table clause

I am new to SQL Server and just joined a company where somebody had created the following stored procedure which I cannot understand. I would like all of you to help me to understand what is going on in this procedure and what can be the alternate way of doing it. Procedure [dbo].[SP_GetUserIncompleteCheckList] ( @GroupID as int, @Bra...

using 32 bit SQL server ODBC on 64 bit system

hi! Microsoft has a SQL server either as 32 bit or 64bit, however the 64bit contains both 32bit AND 64 bit. are there any MSI packages containing the 32 bit AND 64 bit version of the ODBC connector ? i.e. the install package decides by itself which version to install`? ...

SQL Server data types: Store 8-digit unsigned bumber as INT or as CHAR(8) ?

Hello, i think the title says everything. Is it better(faster,space-saving according memory and disk) to store 8-digit unsigned numbers as Int or as char(8) type? Would i get into trouble when the number will change to 9 digits in future when i use a fixed char-length? Background-Info: i want to store TACs Thanks ...

Sql server 2005 :- IO statistics for both IF EXISTS and COUNT(*) > 0 Same?

EDIT :- With PK on the Id column following is produced both for EXISTS and COUNT(*) > 0 Table 'TableWithHugeData'. Scan count 0, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. IF OBJECT_ID('TableWithHugeData') IS NOT NULL BEGIN DROP TABLE TableWithHugeData E...

How do you install an ADO.NET managed data provider onto SQL Server 2005?

I'm trying to install the sforce managed data provider on SQL Server 2005 but as there is no installer, just a dll, I'm not sure on how to go about it. Any ideas? ...

select the sum of every client's last order

Hello, My data is as follows: ORDER_ID CLIENT_ID DATE VALUE 1881 51 2010-07-19 100.17 1882 50 2010-07-19 100.17 2754 50 2010-07-25 135.27 2756 50 2010-07-25 100.28 5514 50 2010-07-27 121.76 5515 50 2010-07-28 109.59 5516 50 2010-07-27 135...

Using same tables alternatively in IN clause returns different results - I was expecting same!!

I have read two excel sheets in two temp tables, #temp and #temp1 Replacing the tables in IN Clause returns different resutls. I was expecting the same. Can anyone explain? select * from #temp where name in (select comp_name from #temp1) Returns 473 records. select * from #temp1 where comp_name in (select name from #temp) Returns 1...

SQL Server 2005: stored procedure to move rows from one table to another

Hello, I have 2 tables of identical schemea. I need to move rows older than 90 days (based on a dataTime column present in the table) from table A to table B. Here is the pseudo code for what I want to do SET @Criteria = getdate()-90 Select * from table A Where column X<@Criteria Into table B --now clean up the records we just moved ...

Which Express Edition to go with: SQL Server 2005 or 2008 R2?

For migrating my old database from MySQL to SQL Server, which edition is suitable, 2005 or 2008 R2? Some developers suggested me to stick to the old version. Suggest Pros and Cons. I will be using with my .NET standalone Windows app. ...

roll backin all the records in sql server

My interviewer asked me Question that i am inserting 10 rows in database table and in some 5th row i find the some trouble then how can i roll back all the records? Please let me know how can i do this ...

Search a keyword and retrieving column where it was found?

I have some tables, Ex.: Car(id, NameCar) and Person(id, PersonName, Address, etc) I need to search for a keyword and say in which columns I found it. Example: Search for Civic, return Person with id 10 have Civic at Car Name, and at Address Name. How can I do this with good performance? ...

parsing Hierarchical self-join table by tree level?!

Hi friends, I have a self referential category table as you see: I want to parse this table to find out tree level for each category. for example if root node level is 0 then CPU and Hard Drive and VGA and RAM are in level 1 and so on. how can I handle that? I created a dictionary to put each category ID and its Level: Dictionary<int...

SQL BETWEEN Operator

Why am I getting '2009' data? What am i doing wrong with the WHERE Clause? SELECT CONVERT(varchar, EventDate, 101) AS EVENTDATE, CONVERT(varchar, ClosedDate, 101) AS CLOSEDDATED, DATEDIFF(Day,EventDate,ClosedDate) AS DiffDate, FROM mytable WHERE (CONVERT(varchar, EventDate, 101) BETWEEN '04/01/2010' AND '04/30/2010')...

Script to save varbinary data to disk

I have some varbinary data stored in a table in MS Sql Server 2005. Does anyone have SQL code that takes a query as input (lets say the query guarantees that a single column of varbinary is returned) and outputs the bytes to disk (one file per row?) I'm sure this has been asked a thousand times before, but Googling comes up with mostly...

Selecting GETDATE() function twice in a select list-- same value for both?

Hi everyone, I have a SELECT statement that uses GETDATE() for two different column values. I'm wondering if by the nature of things those two separate function calls in the same SELECT will return identical values every time? ...