insert default value in sql union query

kobiashi

Registered User.
Local time
Today, 12:47
Joined
May 11, 2018
Messages
258
hi

i am trying to insert a default value in my SQL union script, but it doesnt seem to like what im using, please can some one take a look and let me know if im using the wrong method please, so below is the first part of the union query and where im trying to insert the default value:

Code:
SELECT SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.MCUDate, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_DropdownLists.ListName, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.RSAttention_IDFK, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.EntryType_IDFK, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.MaximoStatus_IDFK, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.MCUTime, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.ServiceRemoval_IDFK, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Title, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.MaximoNumber, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.WorkType, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_DropdownLists_2.ListName, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_DropdownLists_3.ListName, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_DropdownLists_4.ListName, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_Vehicles.VehicleNumber, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_Vehicles_1.VehicleNumber, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_Vehicles_2.VehicleNumber, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Table_Vehicles_3.VehicleNumber, SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.Consist,
ISNULL([SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.InServiceEntryType], 'AfterAMPeak') AS SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.InServiceEntryType
FROM SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak
UNION ALL

this is what i was using

Code:
ISNULL([SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.InServiceEntryType], 'AfterAMPeak') AS SubQuery_ENG_MCU_InServiceIssues_AfterAMPeak.InServiceEntryType


im trying to union multiple select queries, im not sure if that makes a difference.
 
IsNull() is a test for Null, not a replacement. I suspect you want the Nz() function. I'd also just alias with a name, not with the query first:

Nz(...) As InServiceEntryType
 
IsNull() is a test for Null, not a replacement. I suspect you want the Nz() function. I'd also just alias with a name, not with the query first:

Nz(...) As InServiceEntryType

Awsome, worked a treat, thank you.
 

Users who are viewing this thread

Back
Top Bottom