Change default date time format on a single database in SQL Server

You could use SET DATEFORMAT, like in this example declare @dates table (orig varchar(50) ,parsed datetime) SET DATEFORMAT ydm; insert into @dates select ‘2008-09-01′,’2008-09-01’ SET DATEFORMAT ymd; insert into @dates select ‘2008-09-01′,’2008-09-01’ select * from @dates You would need to specify the dateformat in the code when you parse your XML data


As other already pointed out, the queries return different results and are comparing apples to oranges. But the underlying question remains: which is faster: keyset driven paging or rownumber driven paging? Keyset Paging Keyset driven paging relies on remembering the top and bottom keys of the last displayed page, and requesting the next or previous … Read more

Commas within CSV Data

For this problem the solution is very simple. first select => flat file source => browse your file => then go to the “Text qualifier” by default its none write here double quote like (“) and follow the instruction of wizard. Steps are – first select => flat file source => browse your file => … Read more

SQL Server : SUM() of multiple rows including where clauses

This will bring back totals per property and type SELECT PropertyID, TYPE, SUM(Amount) FROM yourTable GROUP BY PropertyID, TYPE This will bring back only active values SELECT PropertyID, TYPE, SUM(Amount) FROM yourTable WHERE EndDate IS NULL GROUP BY PropertyID, TYPE and this will bring back totals for properties SELECT PropertyID, SUM(Amount) FROM yourTable WHERE EndDate … Read more

How to pass XML from C# to a stored procedure in SQL Server 2008?

For part 2 of your question, see my answer to Stored procedure: pass XML as an argument and INSERT (key/value pairs) for an example of how to use XML within a stored procedure. EDIT: Sample code below is based on the specific example given in the comments. declare @MyXML xml set @MyXML = ‘<booksdetail> <isbn_13>700001048</isbn_13> … Read more

ExecuteScalar vs ExecuteNonQuery when returning an identity value

As suggested by Aaron, a stored procedure would make it faster because it saves Sql Server the work of compiling your SQL batch. However, you could still go with either approach: ExecuteScalar or ExecuteNonQuery. IMHO, the performance difference between them is so small, that either method is just as “proper”. Having said that, I don’t … Read more