Archivo de la categoría: SQL Server

Bitacora de SQL Server

SQL Duplicates Count Query for two or more columns

This query uses a commonly used query (CTE) to group the results and count duplicates in the zip_to_fips table. The first part of the query, the CTE, selects the columns «fips», «cnty_name» and adds an additional column «DuplicateCount» that uses the ROW_NUMBER() function to assign a unique number to each row that has equal values… Leer más »

User, group, or role already exists in the current database

You moved the database to another instance and created a new login for this database instead of moving the login from the old instance to the new instance. I recommend that you read my article “How To Move Logins To Another Instance(sp_help_revlogin)”. You may receive this error when you want to authorize the login that you created for the database… Leer más »

SQL query to get start and end date from a result set

-1 I am working on one of requirement the raw data is in following format Requirement – Startdate should be the date when status changed to 1 and enddate should be the 1st date after the record status changed from 1 to any other number. Customer Status Date A123 0 7/2/2021 A123 0 7/15/2021 A123 0… Leer más »