sql-server

Intermittant problems connecting to SQL 2000 servers from SSMS 2008

We're having some intermittant connection problems connecting to our few SQL 2000 servers, but only seemingly from our SSMS 2008 workstations - there don't appear to be any actual business applications that aren't able to connect. Most of the time, SSMS connects just fine, but sometimes, I'll need to manually set the connection protocol ...

Simple query regarding WCF service.

Hi All, I have a WCF service which has two methods exposed: Note: The wcf service and sql server is deployed in same machine. Sql server has one table called employee which maintains employee information. Read() This method retrieves all employees from sql server. Write() This method writes (add,update,delete) employee info in emplo...

remove duplicate record based on time updated..

DocID | Date Updated | DocName 8245376 | 8/26/2009 1:07:01 PM | Doc1 8245376 | 8/26/2009 4:07:04 PM | Doc1 8245376 | 8/26/2009 7:07:01 PM | Doc2 8245376 | 8/26/2009 2:07:03 PM | Doc2 646681 | 8/26/2009 1:07:01 PM | Doc3 263272 | 8/26/2009 1:07:01 PM | Doc4 8245376 | 8/26/2009 1:07:01 PM | Doc5 8245376 | 8/26/2009 2:07:10 PM ...

SQL query to display db data

I have the following database table: Answer MemberID | QuestionNo | AnswerNo | AnswerString 10 | 1 | 2 | q1 anwer2 10 | 2.1 | 3 | q2.1 answer3 10 | 2.2 | 5 | q2.2 answer5 10 | 7 | 1 | q7 answer 7 11 | 1 | 3 | q1 a...

how to set the columnvalues to a variable in store procedure

Hi, using a strored procedure i get a field like this FileNo 0001 0002 0003 how to get this as 0001,0002,0003 pls help.. ...

How to update a column fetched by a cursor in TSQL

Before I go any further: Yes, I know that cursors perform poorly compared with set-based operations. In this particular case I'm running a cursor on a temporary table of 100 or so records, and that temporary table will always be fairly small, so performance is less crucial than flexibility. My difficulty is that I'm having trouble findi...

Efficent opening balance calculation in SQL

I'm looking for a good approach for calculating and caching periodic opening account balances using SQL. I know I can use SQL to sum up a bunch of transactions from start of time to the start of the period in question, but I'm more interested in whether its worth caching those calculated balances (at various points in time) in another ...

SQL CASE Statement Not Working Correctly

I have a view in SQL Server 2008 with several columns that are expressions of one column divided by another. I have to account for the divisor being 0, so I use a CASE statement. Here is an example of one: CASE SUM(dbo.GameStats.BringBacksAttempted) WHEN 0 THEN 0 ELSE SUM(dbo.GameStats.BringBacks) / SUM(dbo.GameStats.B...

Sql Server Reporting wrap output rows

With Sql Server Reporting Services I would like to generate a report with line details for some orders like this: Order Details 2315 1x5432 Apple Tree, 9x912 Roses, 1x13 Spade 2316 3x12 Lawn grass How could I do that most effectively, either with transact sql or by using something built into Reporting Services? (I might end up w...

SQL Service Broker vs Custom Queue

I am creating a mass mailer application, where a web application sets up a email template and then queues a bunch of email address for sending. The other side will be a Windows service (or exe) that will poll this queue, picking up the messages for sending. My question is, what would the advantage be of using SQL Service Broker (or MSMQ...

How do aggregates (group by) work on SQL Server?

How does SQL Server implement group by clauses (aggregates)? As inspiration, take the execution plan of this question's query: select p_id, DATEDIFF(D, MIN(TreatmentDate), MAX(TreatmentDate)) from patientsTable group by p_id Before query data, simple select statement and its execution plan is this: After retrieving the data with t...

Consideration DECS vs SSIS?

I need solution to pump data from Lotus Notes to SqlServer. Data will be transfered in 2 modes Archive data transfer Current data transfer Availability of data in Sql is not critical, data is used for reports. Reports could be created daily, weekly or monthly. I am considering to choose from one of those solutions: DESC and SSIS. Co...

Counting DISTINCT over multiple columns

Is any better way of doing a query like this: SELECT COUNT(*) FROM (SELECT DISTINCT DocumentId, DocumentSessionId FROM DocumentOutputItems) AS internalQuery I need to count the number of distinct items from this table but the distinct is over two columns. I hope that makes sense. ...

Why are my accented characters breaking in SQL Server 2005?

When I update my database with this command: UPDATE myTable SET Name = 'Hermann Dönnhoff' WHERE ID = 123; SQL Server actually puts 'Hermann Do¨nnhoff' in the field instead. Instead of faithfully inserting the o-umlaut (char(246)), I'm getting two characters ( char(111) + char (168) ). This happens for all characters that have accent ma...

SQL Server Linked Server Usage Stats

I have a couple of old sql servers with linked servers set up between them. Is there any way from the logs I can figure out when the linked servers were last used by a query (I want to get rid of the linked server) ...

insert text field from MSSQL to MYSQL failed

I'm trying to income data from a MSSQL (2005) table to MYSQL (5) table, using SSIS, all fields insert correctly. Except one field that his type is TEXT in MSSQL to MYSQL TEXT field, and always this field is get NULL ! ...

How to get the start time of an SQL process?

A job running on our SQL server failed. We are running MS SQL server 2005. While investigating, the following question came up: When was this process initiated on the server? Is there any query I can run that will give me this information? ...

change reports datasource through sql script in SQL Server reporting services

i need an sql script that is going to change the datasource of all reports that are inside of some folder, for example http://localhost/Reports/f1 i have 2 datasources(d1 and d2) and 2 folders (f1 and f2) with reports all the reports from f1 have as datasource d2 and i need to set them to d1 ...

SQL Server 2005 - Row_Number()

Hi All, I'm trying to understand the unusual behaviour seen when ordering results in a descending order using the row_number() function when using a DISITINCT on the outermost select in my query as below: SELECT DISTINCT (ID), State_Id, Name_Of_Trip, Date_Of_Travel, Creation_Date, Locking_Id, Applicant_Name, Reference_Number, Stat...

SQL: What is INSERT INTO #table?

I wanted to know what does the # symbol mean? Why is it being used? Example: INSERT INTO #tmpContracts (sym, contractCount) SELECT sym, COUNT(DISTINCT(fulloptionsym)) AS contractCount ...