I have a SP which is populating a table (LOINT_Master) from another (LTMSPF).
The problem is that when the field LTMSPF.LTXDS1 contains an ampersand ("&"), the ampersand is stripped out of the corresponding CHAR field in LOINT_Master (LOINT_Master.Property_Location).
LTMSPF was populated from as AS/400 file (same structure). The two fields are both defined as char(70), however, LTMSPF.LTXDS1 is not nullable, while LOINT_Master.Property_Location is nullable.
How can I preserve the ampersands?
Here is insert statement:
Thanks in advance.
-- Francis
Et cognoscetis veritatem, et veritas liberabit vos.
The problem is that when the field LTMSPF.LTXDS1 contains an ampersand ("&"), the ampersand is stripped out of the corresponding CHAR field in LOINT_Master (LOINT_Master.Property_Location).
LTMSPF was populated from as AS/400 file (same structure). The two fields are both defined as char(70), however, LTMSPF.LTXDS1 is not nullable, while LOINT_Master.Property_Location is nullable.
How can I preserve the ampersands?
Here is insert statement:
Code:
INSERT INTO dbo.Loint_Master
(
Location_Cd
, Customer_Number
, Status_Code
, Last_Name
, First_Name
, Spouse_First_Name
, Acct_1_Company
, Account_1_Prefix
, Account_1
, Acct_2_Company
, Account_2_Prefix
, Account_2
, Acct_3_Company
, Account_3_Prefix
, Account_3
, Acct_4_Company
, Account_4_Prefix
, Account_4
, Acct_5_Company
, Account_5_Prefix
, Account_5
, Account_1_Notes
, Account_2_Notes
, Account_3_Notes
, Account_4_Notes
, Account_5_Notes
, Property_Type
, Preneed_Filing
, Interment_Flag
, Infant_Of_Flag
-- Property Location:
, Property_Location
, Update_Date
, Misc_Flag_1
, Misc_Flag_2
, Update_User_ID
)
SELECT
LTMSPF.Location_Cd
, LTMSPF.LTXCST
, LTMSPF.LTXXST
, LTRIM(RTRIM(LTMSPF.LTXXLN))
, LTRIM(RTRIM(LTMSPF.LTXXFN))
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXXSP)), '')
, NULLIF(LTMSPF.LTANC1, 0)
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANP1)), '')
, NULLIF(LTMSPF.LTXAN1, 0)
, NULLIF(LTMSPF.LTANC2, 0)
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANP2)), '')
, NULLIF(LTMSPF.LTXAN2, 0)
, NULLIF(LTMSPF.LTANC3, 0)
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANP3)), '')
, NULLIF(LTMSPF.LTXAN3, 0)
, NULLIF(LTMSPF.LTANC4, 0)
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANP4)), '')
, NULLIF(LTMSPF.LTXAN4, 0)
, NULLIF(LTMSPF.LTANC5, 0)
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANP5)), '')
, NULLIF(LTMSPF.LTXAN5, 0)
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANT1)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANT2)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANT3)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANT4)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTANT5)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXXPT)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXPRF)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXINT)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXINF)), '')
-- Property Location:
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXDS1)), '')
, CASE ( ISDATE(CAST(LTMSPF.LTXXMM AS VARCHAR(2)) + '/'
+ CAST(LTMSPF.LTXXDD AS VARCHAR(2)) + '/'
+ CAST(LTMSPF.LTXXYR AS VARCHAR(4))) )
WHEN 1
THEN CAST(CAST(LTMSPF.LTXXMM AS VARCHAR(2)) + '/'
+ CAST(LTMSPF.LTXXDD AS VARCHAR(2)) + '/'
+ CAST(LTMSPF.LTXXYR AS VARCHAR(4)) AS DATETIME)
ELSE CURRENT_TIMESTAMP
END
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXXF1)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTXXF2)), '')
, NULLIF(LTRIM(RTRIM(LTMSPF.LTUSER)), '')
FROM
dbo.LTMSPF
ORDER BY
LTMSPF.Location_Cd
, LTMSPF.LTXCST
Thanks in advance.
-- Francis
Et cognoscetis veritatem, et veritas liberabit vos.