none
Alter View -Two New Feilds Adding RRS feed

  • Question

  • Hello All,

    We have a view that is created on the DB to bring in all the records for a request into a single column . Below is the View

    CREATE

    View [dbo].[Policies] as


    WITH

    view1 AS


    (


    SELECT DISTINCT Reqno FROM CustPolicies


    )


    SELECT


    a

    .reqno,


    STUFF(b.Pol,1,1,'') as Pol



    FROM


    view1 a

    OUTER APPLY


    (


                  

    SELECT ',' + Pol

                  

    FROM   CustPolicies p

                  

    WHERE p.[Reqno] = a.[Reqno]

                         

    FOR XML PATH('')


    ) b(Pol)


    GO

    We would like to add two new fields to this view .

    1. the first field should have 6 preceding zeroes and each policy separated by a coma

    1. Example 1  000000123456
    2. Example 2 000000123456,0000009876543,000000675432

    2. Another field to have the same 6 preceding 6 zeroes and concatenated between single quotes

    1. Example 1 – ‘000000123456’
    2. Example 2 ‘000000123456’,’0000009876543’,’000000675432’

    How do I add these two fields to the view

    Thanks


    Vamsi

    Monday, June 17, 2019 3:09 PM

All replies