sql-server

Incorrect syntax near @[parameter name] when using parameterised Alter Database command

I'm trying to drop a SQL Server database using the following code: SqlCommand command = new SqlCommand("USE MASTER; ALTER DATABASE @database SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE @Database", connection); command.Parameters.AddWithValue("@database", TestingEnvironment.DatabaseName); command.ExecuteNonQuery(); When I ex...

The application sorts strings differently than the database

I am trying to sort a list of products by their name in a .Net application written in C#, to obtain the same list that I would get from an SQL Server database through an order by: select * from Products order by ProductName Unfortunately, the application sorting behaves differently than the database sorting. It is probably related to th...

SQL CE Merge Replication: Error 28532: A read operation from the transport returned no data.

Hi, I am using sql server 2005 and ce framework 3.5 and attempting to use merge replication between my hand held and my sql server. I am getting the following error: Error 28532 : A read operation from the transport returned no data. The version of SQL Server Compact 3.5 Client Agent and SQL Server Compact 3.5 Server Agent should matc...

Why is SSRS ignoring data from certain columns returned by a web method?

I'm using the XML data source feature in Reporting Services 2005 but having some issues with missing data. When there is no value for the first column in a row, it appears that the entire column is ignored by SSRS! The web method request is very simple: <Query> <Method Name="GetIssues" Namespace="http://www.mycompany.com/App/"&gt; ...

What's the best way to store a title in a database to allow sorting without the leading "The", "A"

I run (and am presently completely overhauling) a website that deals with theater (njtheater.com if you're interested). When I query a list of plays from the database, I'd like "The Merchant of Venice" to sort under the "M"s. Of course, when I display the name of the play, I need the "The" in front. What the best way of designing the ...

Amazon EC2 Sql Performance

Hi, I'm considering using Amazon's EC2 with a windows instance & SQL. I've seen some criticism of the perf of the SQL instances here. I'm wondering if any SOers have and first hand experience and can comment on the performance. ...

T-SQL : Using { fn NOW() } in WHERE

I was reviewing some SQL queries and I saw a select statement that looked like this SELECT * FROM dbo.mytable WHERE (dbo.mytable.[Date] < { fn NOW() }) What is the purpose of using a WHERE statement like this? Wouldn't be easier to use a simple GETDATE()? ...

question on how to use sql server integrated service

I have a table called book with, the attrbutes are booked_id, yearmon, and day_01....day_31. Now i need to unpivot the table and transform day_01...day_31 into rows, I have successed in doing that, but the problem is that my yearmon is a format of 200805 and i need to append a day to it based on day_01 or day_02 etc, so that i can create...

Are foreign keys indexed automatically in SQL Server?

Would the following SQL statement automatically create an index on Table1.Table1Column, or must one be explicitly created? Database engine is SQL Server 2000 CREATE TABLE [Table1] ( . . . CONSTRAINT [FK_Table1_Table2] FOREIGN KEY ( [Table1Column] ) REFERENCES [Table2] ( ...

How to find timed out statements in SQL 2005 profiler

I'm trying to find SQL statements that timed out using the SQL 2005 profiler. Is there a way to set such a filter? ...

Fold in T-SQL?

If I have data in the following format id subid text 1 1 Hello 1 2 World 1 3 ! 2 1 B 2 2 B 2 3 Q And would like it in this format: id fold 1 HelloWorld! 2 BBQ How could I accomplish it in T-SQL? ...

Background filling a DataGridView from an SqlDataAdapter

I have a large dataset (over 100,000 records) that I wish to load into a DataGridView. The stored procedure that does this can take 10 seconds or more to complete. So far I have a BackgroundWorker preventing the UI from locking up, and have implemented a rudimentary 'Please Wait' dialog. What I'd like to do is somehow populate the Data...

SQL Connection Pooling and Audit Login/Logout

When I profile my application using SQL Server Profiler, I am seeing lots of Audit Login and Audit Logout messages for connections to the same database. I am wondering, does this indicate that something is wrong with my connection pooling? The reason I ask, is because I found this in the MSDN documentation in regards to connection pool...

Why does this SQL script work as it does?

I'm pulling email address records from a table in SQL Server 2005, and want to build a single string to use as the @recipients list with sp_send_dbmail. The table has a field called EmailAddress and there are 10 records in the table. I'm doing this: DECLARE @email VARCHAR(MAX) SELECT @email = ISNULL(@email + '; ', '') + EmailAddres...

Compatibility

Hi Friends, Actually I have to find out the compatibilty of the upgrade of MSSQL 2000 to MSSQL 2005. The MSSQL 2000 was installed inside the Citrix box . I did a side by side upgrade by backing up the database and restoring in my local machine. Now I have to figure out if the applications will work in MSSQL 2005.Can somebody please, give...

How can I convert Geometry data into a Geography data in MS SQL Server 2008?

How can I convert some Geometry data into Geography data in MS SQL Server 2008? ...

Obtaining my custom error message from SQL 2000 sp

I have an sp with the following pseudo code... BEGIN TRANSACTION set @errorLocation='Deleting Permissions' DELETE [tblUsrPermissions] WHERE lngUserID = @lngUserID if @@error>0 begin goto roll_back end COMMIT TRANSACTION set @errorLocation='' --clear error messages ...

Batch script for re-creating database from source control

Hi Everyone, As far as I understand, if I want to get my database under source control then I need to be checking in change scripts for each change and then running them from some revision to get the correct DB. I am trying to make a batch file that will be checked in too, that allows other developers on the team to re-build the DB loc...

Problem with date day/month reversing on save

We have a problem affecting the production environment only. We have a VB6/ASP website that allows for data in a database table to be hand edited. It looks alot like an editable datagrid. One of the editable columns is a date and when the record is saved dates day/month are being reversed. 03/11/2008 becomes 11/03/2008, if you were t...

Retrive Records Form One Table as long as they do not exist in Another table T-SQL

Hi, I need to wite a query that will retrieve the records from Table A , provided that the key in Table A does not exist in Table B. Any help will be appreciated. Thanks ...