Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
0 answers
80 views

Sanity Check - Result set different after breaking up case expression in where clause into different selects w/union all

I'm back again with more dumb questions. This time I am dealing with refactoring a single select with nested case expressions in the where clause. I'm trying to optimize this, and in attempting to do ...
scarr030's user avatar
  • 115
2 votes
1 answer
336 views

About Apex SQL Refactor and SSMS keyboard shortcuts being broken

Hi DBA Stack Exchange! Today I tried Apex SQL Refactor and right from the get go, once installed and integrated into my T-SQL dev tool of Choice (SSMS 18.3.1) I noticed that some Keyboard shortcuts ...
Martin Surasky's user avatar
1 vote
1 answer
63 views

Refactoring database after migrating table

I'm creating a new staging database, into which I intend to migrate several tables from the old database. These tables are referenced in functions and stored procedures. If I were doing things ...
N4v's user avatar
  • 135
1 vote
1 answer
678 views

Refactoring sql for tables with similar columns but different table names

I have the task of re-factoring a SQL script that performs a lot of unions from different tables. These tables have similar information, so the script queries the same columns as in each table, except ...
info_seekeR's user avatar
1 vote
1 answer
3k views

Find Duplicate Customers

Okay... I have a table that has customers: -- Individual Table * ID (Internal Unique ID) * IndividualID (External Unique Individual Identifier) * Last Name * First Name * Birth Date * SSN * ... The ...
WernerCD's user avatar
  • 1,225
7 votes
3 answers
23k views

Is there a more concise way to convert a UTC datetime into a local date only?

I am trying to write a query that groups records based on the local date part only of a UTC datetime field. For example, if my table contains 10/19/2012 2:00:00, then it should get grouped as 10/18/...
Rachel's user avatar
  • 8,537
12 votes
3 answers
780 views

Are these two queries logically equivalent?

Are these two queries logically equivalent? DECLARE @DateTime DATETIME = GETDATE() Query 1 SELECT * FROM MyTable WHERE Datediff(DAY, LogInsertTime, @DateTime) > 7 Query 2 SELECT * FROM ...
Alf47's user avatar
  • 971