IF OBJECT_ID(‘tempdb..#TEMP_AP_INVOICE’) IS NOT NULL DROP TABLE #TEMP_AP_INVOICE
Category SQL 2014
Cannot resolve the collation conflict between “Latin1_General_CS_AS” and “SQL_Latin1_General_CP1_CI_AS” in the equal to operation.
If this error happens in join, use this solution:
SELECT *
FROM Table1
LEFT OUTER JOIN Table2 ON Table2.ID = Table1.ID collate SQL_Latin1_General_CP1_CI_AS
Delete duplicate records in SQL Server?
Use this script at you own risk. I am not responsible for any accidental mass amount of your data get deleted. Always use begin tran and rollback tran to make sure you know what are you deleting.
BEGIN TRAN
DELETE x
FROM ( SELECT *, rn=row_number() over ( partition by [DELETED] ,[NETBIMDER] ,[PG_DEPT] ,[EMAILNOTIFICATION] order by ID ) from ND_LOG ) xwhere rn > 1
ROLLBACK TRAN
TO see what will be deleted, use this:
SELECT *SELECT *FROM ( SELECT *, rn=row_number() over ( partition by [DELETED] ,[NETBIMDER] ,[PG_DEPT] ,[EMAILNOTIFICATION] order by ID ) from ND_LOG ) xwhere rn > 1
ID = Primary key.
7If you don’t have a primary key, you can use ORDER BY (SELECT NULL)
Reff: https://stackoverflow.com/questions/3317433/delete-duplicate-records-in-sql-server
Rebuilding Indexes using the SSMS Database Maintenance Wizard
Usually I do all 3 job under one single task but with separate schedule for each of them:
Reorganize_Index
Rebuild_Index
Update_Statistics
Details can be found here: