Tagged with sql server

Delete duplicated rows on SQL

Assuming these are the incriminated records                   Let’s narrow down the duplicate ones by grouping the records and removing from the resultset the first valid record and by leaving the duplicates only.               Let’s delete them now.   Advertisements

SQL Collation conflict

While attempting to copy ┬árecords from older database backup [sourcecode language=”sql”] update a set latitude = b.latitude, longitude = b.Longitude from newtable a inner join [OldDb].[dbo].[LegacyTable] b on b.name = a.name [/sourcecode] I’ve encoutered the following : Msg 468, Level 16, State 9, Line 5 Cannot resolve the collation conflict between “Latin1_General_CI_AS” and “SQL_Latin1_General_CP1_CI_AS” in … Continue reading

Trim colums in Sql

Remove white spaces from the beginning and the end of a column : UPDATE TableName SET columnOne = LTRIM(RTRIM(columnOne)), SET columnTwo = LTRIM(RTRIM(columnTwo))