sql-server

Join with conditions and aggregate functions

Hi, I have a table in which there are records about works accesing entrance doors. DECLARE @doorStatistics TABLE ( id INT IDENTITY, [user] VARCHAR(250), accessDate DATETIME, accessType VARCHAR(5) ) Sample records: INSERT INTO @doorStatistics([user],accessDate,accessType) VALUES ('John Wayne','2009-09-01 07:02:43.000','IN') INSERT IN...

MS SQL update to Integrated Security

Hi: For debugging purpose, I backedup one of QA database and restored to local machine. Since it is in my local machine, I just want to connect to it using Integrated Security=True in my asp.net application. But I am getting following error: Cannot open database "db1" requested by the login. The login failed. Login failed for us...

SQL: How do I select an XML element from within a larger variable of type XML?

I am sending multiple different data items to a stored procedure in an XML variable. The signature of the function goes something like this: CREATE PROCEDURE MyProc @id INT, @xml xml AS BEGIN .... END and the XML looks somewhat like this: <Root> <SampleTime>2009-02-05 13:25:43</SampleTime> <Gizmo1> <Voltage>34.1</Vol...

Reporting Services Interactive Sort problem

I have a set of reports defined for Reporting Services in SQL 2005. I'm rendering the reports using the ReportViewer control inside an ASP.NET 3.5 application. In all the reports I have a chart and a table where interactive sorting is implemented. The sorting works perfectly when I test it on the report server catalog page. But in the re...

Split Ms Sql 2005 Table to two or more parts

I need to split an existing table in to two or more tables on Sql Server 2005. The table already has more than a thousand of rows. For eg current table has cols A, B, C, D, E plus an id column. An I need to add A, B, C rows to another table in another database and add D, E to another table in another database. I know that it is weird. ...

Data has always changed(SQL Server Management Studio)

Hi, I am using SQL Server Management studio and keep getting the same error, and the only way to get rid of it(usually) is to reset the SQL server(which is very annoying, and sometimes impossible from my remote machine) When I add a row to a table, and then I goto "Edit Top 200 Rows" it all displays and acts fine, and I go to a field I ...

Logging Stored Procedures Errors in a SQL Server 2005 Database

I'm using the general construct shown below for my TSQL stored procedures. This works fine for returning the error information to the calling application code. However, I would also like to log the error in the database itself. How can I accomplish this in SQL Server 2005? BEGIN TRY TSQL... END TRY BEGIN CATCH DECLARE @ErrorMessage N...

Importing CSV data into SQL Server using the wizard - cryptic error messages...

I'm trying to use the SQL Server Import Wizard to import flat text file into SQL Server. Seems like this should be pretty simple. The text file is tab-delimited, with nothing unusual about it. When I preview the data in the wizard, everything looks OK. I've checked the column mappings, and all the data lines up, and the data types all ...

How to synchronise web application database with a windows appplication database

I am having two databases for the same application , one in windows and the other is web based.Since web based one have few functionalities I can't opt for a single database.At the same time I want to share Both databases to be updated with other's data so as to work error free with my module of appointment fixing.If anyone have a nice...

how to insert data into table from stored proc, manual values together in a single insert statement

Can anyone tell me how to insert a record in a table in the following case: I have 2 tables: create table #temp1(c4 int, c5 int,c3 int) ...and: create table #temp2(c1 int, c2 int) create procedure sptemp as begin select c1,c2 from #temp2 end Now I want to insert records into #temp1 table using the procedure as: insert in...

Retrieving failing package and error message in SSIS

I want to make a general error handling package that should be called from my other packages when something goes wrong. In this error handling package I want to log what task failed and the reason for the failure. How can I retrieve this information? I'm using the Control Flow Failure precedence constraint to point out a Execute Package...

My SQL insert/update statement is too inefficient

I'm trying to write code for a batch import of lots of rows into the database. Currently I bulk copy the raw data (from a .csv file) into a staging table, so that it's all at the database side. That leaves me with a staging table full of rows that identify 'contacts'. These now need to be moved into other tables of the database. Next I...

Microsoft SQL server 2008 and UTF-8

A colleague tells me that there is no way to bulk insert UTF-8 encoded data into a Microsoft SQL server 2008. Can this be true? Is there any stuff you would recommend him to read or look at? ...

Can someone please help me to correct this SQL 08 query?

When I run the below SQL 08 query I get an error that tbrm_Article.ArticleID is invalid because it is not contained in an aggregate function or GROUP BY clause. I know the problem is related to the: AVG(tbrm_Votes.True) AS Truth, AVG(tbrm_Votes.False) AS False, and the subsequent join to the tbrm_Votes table. the tbrm_votes ta...

DataSet Designer - Auto Add Columns

Hi, in my VB.Net application I've created a Dataset that call an existing MS SQL Server stored procedure but after the wizard close no columns where added... how can I add all the columns returned by the stored procedure without adding them manually (off course the stored procedure might change in the future) in which case manually will...

Sql Query to find A series of dates that occur within 5 minutes of each other?

This is Sql Server 2008. I've got a set of data that looks something like this: Table UserAchievement id userId achievementId completedDate When a user earns an award, the award and user is logged along with a date. What I'd like is a query that finds a set of 3 achievements that were earned within 5 minutes of each other ...

The best way to design a Reservation based table

One of my Clients has a reservation based system. Similar to air lines. Running on MS SQL 2005. The way the previous company has designed it is to create an allocation as a set of rows. Simple Example Being: AllocationId | SeatNumber | IsSold 1234 | A01 | 0 1234 | A02 | 0 In the process of selling a s...

Collation conflict in stored procedure while assigning a variable

We are trying to create a stored procedure, however we run into the following error message: Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation. This error occurs at line 33, which reads as follows: SET @MINTIME = (SELECT CONVERT(varchar,DATEADD(MONTH,-1,G...

LINQ to SQL: errors from stored procedure are ignored after result set is returned

I'm using LINQ to SQL to call a stored procedure. This stored procedure currently returns a resultset and then has some raiserror statements being triggered after the resultset is retrieved (I'm writing tests for stored procedures, in case you're wondering why I'm doing this). When LINQ to SQL calls the proc and it gets a resultset bac...

Can this be done in SQL 2008?

Given this data set: SummaryID Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 25 1 2 3 4 5 6 7 6 5 4 3 2 1 2 3 25 1 2 3 4 5 6 7 6 5 4 3 2 1 2 3 25 ...