• Lynn Pettis - Friday, March 15, 2019 4:14 PM

    briancampbellmcad - Friday, March 15, 2019 1:42 PM

    Lynn Pettis - Friday, March 15, 2019 1:36 PM

    briancampbellmcad - Friday, March 15, 2019 12:19 PM

    pietlinden - Wednesday, March 13, 2019 9:58 AM

    If you use RIGHT([oldSSN],4) then the rest shouldn't matter, because you'll never get any of the dashes anyway, because they would be 5th from the right.

    RIGHT([oldSSN],4) just gives me the first 3 characters and a dash, e.g. 235-55-7777 becomes 235-

    That looks more like the results of a LEFT([oldSSN],4).

    Same results... note that this is stored a varchar not integer

    Okay, you are going to have to show me your code.  LEFT and RIGHT are string functions so we are assuming that the data is stored as character data.

    Using your single value sample:

    IF OBJECT_ID('dbo.TestSSNTrim','U') IS NOT NULL
    DROP TABLE [dbo].[TestSSNTrim];

    CREATE TABLE [dbo].[TestSSNTrim](
    [OldSSN] varchar(11));

    INSERT INTO [dbo].[TestSSNTrim]
    (
    [OldSSN]
    )
    VALUES
    (
    '235-55-7777' -- OldSSN - varchar(11)
    );

    SELECT
    [tst].[OldSSN]
    , LeftTrim = LEFT([tst].[OldSSN],4)
    , RightTrim = RIGHT([tst].[OldSSN],4)
    FROM
    [dbo].[TestSSNTrim] AS [tst];

    IF OBJECT_ID('dbo.TestSSNTrim','U') IS NOT NULL
    DROP TABLE [dbo].[TestSSNTrim];
    GO


    OldSSN         LeftTrim RightTrim
    -----------    -------- ---------
    235-55-7777    235-     7777