SQL Sorting and hyphens

I learned something new, just like you as well I believe the difference is between a “String Sort” vs a “Word Sort” (ignores hyphen) Sample difference between WORD sort and STRING sort http://andrusdevelopment.blogspot.com/2007/10/string-sort-vs-word-sort-in-net.html From Microsoft http://support.microsoft.com/kb/322112 For example, if you are using the SQL collation “SQL_Latin1_General_CP1_CI_AS”, the non-Unicode string ‘a-c’ is less than the string … Read more

Milliseconds wrong when converting from XML to SQL Server datetime

Yes, SQL Server rounds time to 3.(3) milliseconds: SELECT CAST(CAST(‘2009-01-01 00:00:00.000’ AS DATETIME) AS BINARY(8)) SELECT CAST(CAST(‘2009-01-01 00:00:01.000’ AS DATETIME) AS BINARY(8)) 0x00009B8400000000 0x00009B840000012C As you can see, these DATETIME‘s differ by 1 second, and their binary representations differ by 0x12C, that is 300 in decimal. This is because SQL Server stores the time part … Read more

Convert SQL server datetime fields to compare date parts only, with indexed lookups

The best way to strip the time portion of a datetime field is using datediff and dateadd functions. DateAdd(day, datediff(day,0, MydateValue), 0) This takes advantedge of the fact that SQL Server stores dates as two integers, one representing the number of days since day “0” – (1 jan 1900), and the second one which represents … Read more

How to update data in one table from corresponding data in another table in SQL Server 2005

If the two databases are on the same server, you should be able to create a SQL statement something like this: UPDATE Test1.dbo.Employee SET DeptID = emp2.DeptID FROM Test2.dbo.Employee as ’emp2′ WHERE Test1.dbo.Employee.EmployeeID = emp2.EmployeeID From your post, I’m not quite clear whether you want to update Test1.dbo.Employee with the values from Test2.dbo.Employee (that’s what … Read more

techhipbettruvabetnorabahisbahis forumu