Click here to Skip to main content
15,867,686 members
Home / Discussions / Database
   

Database

 
GeneralRe: TSQL - Create a JOIN, knowing that it may not exist, but show the initial records at least instead of nothing [solved] - May run with this Pin
jkirkerx21-Nov-22 11:04
professionaljkirkerx21-Nov-22 11:04 
AnswerRe: TSQL - Create a JOIN, knowing that it may not exist, but show the initial records at least instead of nothing [bad idea] - abandoned it Pin
Richard Deeming21-Nov-22 22:02
mveRichard Deeming21-Nov-22 22:02 
GeneralRe: TSQL - Create a JOIN, knowing that it may not exist, but show the initial records at least instead of nothing [bad idea] - abandoned it Pin
jkirkerx22-Nov-22 6:58
professionaljkirkerx22-Nov-22 6:58 
QuestionOrder by several static string values, error "Conversion failed when converting the varchar value 'FX' to data type int" Pin
jkirkerx14-Nov-22 10:44
professionaljkirkerx14-Nov-22 10:44 
AnswerRe: Order by several static string values, error "Conversion failed when converting the varchar value 'FX' to data type int" [sort of solved] Pin
jkirkerx14-Nov-22 11:29
professionaljkirkerx14-Nov-22 11:29 
GeneralRe: Order by several static string values, error "Conversion failed when converting the varchar value 'FX' to data type int" [sort of solved] Pin
jsc4222-Nov-22 10:31
professionaljsc4222-Nov-22 10:31 
GeneralRe: Order by several static string values, error "Conversion failed when converting the varchar value 'FX' to data type int" [sort of solved] Pin
jkirkerx22-Nov-22 10:50
professionaljkirkerx22-Nov-22 10:50 
GeneralRe: Order by several static string values, error "Conversion failed when converting the varchar value 'FX' to data type int" [sort of solved] Pin
jsc4222-Nov-22 23:26
professionaljsc4222-Nov-22 23:26 
GeneralRe: Order by several static string values, error "Conversion failed when converting the varchar value 'FX' to data type int" [sort of solved] Pin
jkirkerx23-Nov-22 6:11
professionaljkirkerx23-Nov-22 6:11 
QuestionCan any body share the schema database for security and share. Pin
Nguyễn Tuấn Anh 9216-Nov-22 5:40
Nguyễn Tuấn Anh 9216-Nov-22 5:40 
AnswerRe: Can any body share the schema database for security and share. Pin
Sam Hobbs6-Nov-22 10:05
Sam Hobbs6-Nov-22 10:05 
AnswerRe: Can any body share the schema database for security and share. Pin
jschell14-Nov-22 6:49
jschell14-Nov-22 6:49 
QuestionHow to avoid duplicate records while using a UNION - SOLVED Pin
Richard Andrew x6428-Oct-22 15:50
professionalRichard Andrew x6428-Oct-22 15:50 
AnswerRe: How to avoid duplicate records while using a UNION - SOLVED Pin
Richard Deeming30-Oct-22 23:01
mveRichard Deeming30-Oct-22 23:01 
Depending on your data, COALESCE is probably not the right approach. You unconditionally execute subquery 2, and only execute subquery 1 if #2 returns Null. That's a change in behaviour from your original query.

You should probably use a CASE statement instead:
SQL
SELECT Column1, Column2, CASE WHEN CRITERIA1 IS TRUE THEN (SUBQUERY1) ELSE (SUBQUERY2) END As SomeData
FROM TABLE1
WHERE CRITERIA1 IS TRUE 
OR CRITERIA2 IS TRUE
If you want to prioritize criteria 2 matches, then swap the case around:
SQL
CASE WHEN CRITERIA2 IS TRUE THEN (SUBQUERY2) ELSE (SUBQUERY1) END As SomeData




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: How to avoid duplicate records while using a UNION - SOLVED Pin
Richard Andrew x6431-Oct-22 1:13
professionalRichard Andrew x6431-Oct-22 1:13 
AnswerRe: How to avoid duplicate records while using a UNION - SOLVED Pin
Andrea Simonassi2-Nov-22 19:55
Andrea Simonassi2-Nov-22 19:55 
AnswerRe: How to avoid duplicate records while using a UNION - SOLVED Pin
PIEBALDconsult6-Nov-22 5:54
mvePIEBALDconsult6-Nov-22 5:54 
GeneralRe: How to avoid duplicate records while using a UNION - SOLVED Pin
Richard Andrew x646-Nov-22 6:56
professionalRichard Andrew x646-Nov-22 6:56 
QuestionAzure Synapse Where myString like '%Pattern1%Pattern2%' Pin
j11codep3-Oct-22 15:02
j11codep3-Oct-22 15:02 
AnswerRe: Azure Synapse Where myString like '%Pattern1%Pattern2%' Pin
CHill606-Oct-22 1:41
mveCHill606-Oct-22 1:41 
QuestionSimple Unique Identity Value Pin
Richard Andrew x6430-Sep-22 10:30
professionalRichard Andrew x6430-Sep-22 10:30 
AnswerRe: Simple Unique Identity Value Pin
Richard Deeming2-Oct-22 22:04
mveRichard Deeming2-Oct-22 22:04 
GeneralRe: Simple Unique Identity Value Pin
Richard Andrew x646-Oct-22 2:00
professionalRichard Andrew x646-Oct-22 2:00 
AnswerRe: Simple Unique Identity Value Pin
CHill606-Oct-22 1:59
mveCHill606-Oct-22 1:59 
GeneralRe: Simple Unique Identity Value Pin
Richard Andrew x646-Oct-22 2:01
professionalRichard Andrew x646-Oct-22 2:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.