Need to ommit the short form letter from the given string

HI,
     I need to ommit the Short form letter from column data.
EX :
CREATE table #testdata
(id int identity(1,1),cust_address varchar(max))
insert into #testdata (cust_address)
select 'first street 5N, North'
union
select 'second street W, west'
union
select 'roja street 5S, South'
union
select 'temple street E, East'
union
select 'first street, Northwest, NW'
union
select 'first street, Southwest, SW'
select  * from #testdata
actutal out put:
id cust_address
1 first street 5N, North
2 first street, Northwest, NW
3 first street, Southwest, SW
4 roja street 5S, South
5 second street W, west
6 temple street E, East
Need to ommit the Short form letter from this output,
condition , 1) the short form letter should have space in front of the letter ex : first street (space)N, North
               so the output should be "first street, North" like that for other words like "first street, Southwest, SW" should be "first street, Southwest"
             2) the short form letter should not combine with any other letter ex :  first street 5N, North
                 here we dont need to do anything.
Required Out put :
id cust_address
1 first street 5N, North
2 first street, Northwest
3 first street, Southwest
4 roja street 5S, South
5 second street, west
6 temple street, East
Nandha Kumar

 CREATE FUNCTION [dbo].[SplitString]
         @str VARCHAR(MAX)
    RETURNS @ret TABLE (token VARCHAR(MAX))
     AS
     BEGIN
    DECLARE @x XML 
    SET @x = '<t>' + REPLACE(@str, ',', '</t><t>') + '</t>'
    INSERT INTO @ret
        SELECT x.i.value('.', 'VARCHAR(MAX)') AS token
        FROM @x.nodes('//t') x(i)
    RETURN
  END
with cte
as
select  *
from #testdata
CROSS APPLY (SELECT * FROM [dbo].[SplitString](cust_address)) AS der
) ,cte1
as
select *,
case when UPPER(token)=token COLLATE Latin1_General_BIN
  then  '' else token end as d 
 from cte
 ) ,CTE2
 AS
 (SELECT *,case when RIGHT(UPPER(D),1)=RIGHT(D,1) COLLATE Latin1_General_BIN 
  then  replace(D,RIGHT(UPPER(D),1),'') else token end d1 FROM CTE1
 SELECT m1.id,
       ( SELECT m2.D1 + ','
           FROM cte2 m2
          WHERE m2.id = m1.id
          ORDER BY id
            FOR XML PATH('') ) AS token
  FROM cte2 m1
 GROUP BY m1.id 
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Hi, I have an older version of imovie on my mac and I need to make a short movie right from the camera inside my mac because my flipshare camera doesn't have the correct software anymore.  Do I definitely need the new version of imovie?

    Hi, I have an older version of imovie and I need to record a short audition directly from my built in camera in imovie and edit it and then send it because my flipshare camera software isn't responding to mailing at all.  Do I need the new imovie version download (update) available or can I simply use what is already on my computer to record edit and send?
    Thanks!

    AS an iLife 08 owner, you can get a free download of iMovie 6 here.
    http://www.apple.com/support/imovie/
    See bottom right of page for iMovie HD download.

  • HT1725 Some songs that I paid for fully downloaded, but it is only playing the small sample piece from the Itunes store. How should I fix this?

    I had a Wish List with about 7 or 8 songs on there and I purchased them today. They all downloaded fine, except for 2. These two songs completed the download from what the computer says, but it will only play the short sample avaliable from the Itunes store. How should I fix this?

    Other people have been having similar problems with songs over the last few days, I assume that there has been a problem with Apple's servers.
    Depending upon what country that you are in (music can't be re-downloaded in all countries) then try deleting them from your iTunes library and redownload them via the Purchased link under Quick Links on the right-hand side of the iTunes store home page on your computer's iTunes : re-downloading.
    If you aren't in a country where you can re-download music or if they re-download in the state then try the 'report a problem' link from your purchase history : log into your account on your computer's iTunes via Store > View My Account and you should then see a Purchase History section with a 'see all' link to the right of it ; click on that and you should see a list of your purchases ; find those songs and use the 'Report a Problem' link.

  • How to get the PO no in the smart form and in the print program from ME23N

    hello all,
                     I am new to smart form printing.I want to make a smartform along with print program that will show PO Details.It has to be created as an o/p type in ME23N. I have created an o/p type ZPO using NACE ..Can some one tell me how to get the PO number in the smart form and in the print program  from ME23N ,so that I can then program the necessary calculations?plz help me with the code.Thanks in advance.
    Subhabrata.

    Hello Everyone,
    I am new to the forum and also to abap.
    Excuse me if it is a basic question.
    I am taking care of the output types.
    This is 1st time SAP will be implemented .
    For purchase order , I go to NACE ---EF----NEU---Processing routines
    print output---SAPFM06P---ENTRY_NEU----MEDRUCK
    FAX-----------SAPFM06P---ENTRY_NEU----MEDRUCK
    EDI------------RANASTED--EDI_PROCESSING
    DISTRIBUTION(ALE)---RANASTED---ALE_PROCESSING
    Are the above settings fine ?
    What are the standard programs for the PO outputs . I am looking for the smartforms and the driver program .
    I searched and found that IN ECC 6 , we have to install OSS notes .
    Gurus, please help  me . Let me know what all oss notes be implemented and how to proceed from here .
    Any help will be greatly appreciated ,
    Monalisa

  • Cannot save the Interactive form downloaded from abap webdynpro application

    Hello Everyone,
    Can anyone help me here.
    I have created an interactive form in SFP tcode and used in abap webdynpro application.
    scenario is i can downloade the form,fill it, sign it,save it and submit the form.
    Some thing is going wrong when i try to sign the form downloaded from the application.It is giving the error ->
    The document could not be saved. there was a problem in reading the document(26).
    When i try to sign the form save as dialog box will come where we can save the filled form.but here when itry to save it is giving above error.and also i cannot save thye form form file option.
    but form is working fine from sfp tcode not form application link.
    What is going wrong.Can somebody please help me here.
    Regards,
    Menaka.H.B

    Check the enabled and readOnly property of the InteractiveFormUI element in your application.
    enabled should be true and readOnly should be false.
    Also just FYI interactive forms are licensable in Productive environment for which you need Adobe Credentials. You may contact SAP Account Manager and Note 736902 for it.
    Chintan

  • I have three different e-mail addresses, and need to receive the incoming e-mails from the three sources.  How do I enable my iPhone to do it? Tks in advance.

    I have three different e-mail addresses, and need to receive the incoming e-mails from the three sources into my iPhone (it's presently receiving msgs from only one of them).  How do I enable my iPhone to do it? Tks in advance.

    Many thanks for your help!

  • Assign Task to a specific user based on the value of DDL from the form

    Hello,
    Can any one please advise me on how to assign a task to a specific user based on the value of the drop down list from the form. E.g. user fills the form and before they submit the form they have to select one of the name from the drop down list so the form can go to that person for approval.
    Thanks in advance,
    Han

    I got it works now by using the xpath expression (in workbench) to assign to the selected user from the DDL in the form.

  • Need some help with downloading PDF's from the net.

    need some help with downloading PDF's from the net.  Each time I try to click on a link from a website, if it takes me to a new screen to view a pdf, it just comes up as a blank black screen?  any suggestions?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • How find print program and form name from the spool list

    Hi,
          I have a requirement to find print program and form name from the spool list.
    I got the list of programs and forms from TNAPR table, I also want to find out any custom program sending the form directly to the spool.
    Cheers
    Sam

    Hi
    Try TSP01-Suffix2
    Regards
    Raj

  • If I need to buy more iCloud storage, will the money be taken from the cc I have on file or can it come from money I have in my iTunes account?

    I need more iCloud coverage. I want the money to come from the balance I have in my iTunes account and not from the cc I have on file. Is that possible?

    I should have said exactly as in your post body as opposed to the heading! They are opposites!

  • Hi, I need the program of access from the office, so i'm going to but the Microsoft office 365 university, will i have to but any other program to use the access from my mac? or to open any database that I will have did from any other computer (not mac)?

    hi, I need the program of access from the office, so i'm going to but the Microsoft office 365 university, will i have to but any other program to use the access from my mac? or to open any database that I will have did from any other computer (not mac)?

    There has never been a Mac version of Access. Microsoft never created one, realising that it was very inferior to the FileMaker Pro database application.
    So if you must run Access you will have to run Windows on your mac.

  • Hi. I made a modern resume from the pages template and then made a modern letter from the templates, how do I combine the two into one PDF file in Pages? Thank you.

    Hi. I made a resume from the modern template in Pages, then I made a letter from the modern template in Pages. How do I combine the two (cover letter and resume) into one PDF file. Thanks in advance.

    Open them both in Preview.app and drag the thumbnail of one into the other,
    Peter

  • My MBP can't input chinese hand writing letter when I selected a letter from the writing pad?

    my MBP (OS X Lion 10.7.5) can't input chinese hand writing letter; it didn't response when I selected a letter from the trackpad!

    cor-el,
    Thank you very much for your advice. The new software of Penpower works rightaway after I installed it on my pc. Thanks again.
    十分感激你的幫忙!

  • Need to load complete preview before playing from the iTUNES STORE  No such selection.

    REBUFFERING STREAM is constant during preview of songs.   The solution suggested by the community was to: Go to iTUNES preferences>STORE and select "LOAD COMPLETE PREVIEW BEFORE PLAYING.   I tried that but the STORE does not offer this option.   WHAT NEXT?

    I have the same problem with my iphone 4 . I solve it with giving permission to the cookies on safari from the settings.

  • Can the individual form response be sent via e-mail to us in the PDF form format (not the raw output we see currently when using e-mail notifcation) each time a user submits a reponse?

    Hi, we basically have an on-line job application that we need to be sent to us via e-mail notification every time a user submits a response, not with the raw data output from the form fields like the current e-mail notification setting allows, but as an actual PDF attachment that mirrors the format of the on-line form, with the user response data in it. We need this to be automated and sent to a central HR e-mail to distro to others. It would be essentially the same thing as a user downloading a PDF form, filling it out, then e-mailing it back to us, but using the submit options via the Form Central server instead. Is this even possible and, if so, is there any documentation on it? I have not found anything clear in searching for this same topic.

    No this is not possible within Formscentral. You could export a PDF without a submit button (an option when saving your form as PDF) and then in Acrobat add a submit button to your form and have it automatically sent to the email of your choice. This kind of workflow falls outside the scope of Formscentral.
    Andrew

Maybe you are looking for

  • Problem with SATA hard discs and MSI motherboards (could it be the SATA cable)

    I have two systems with a Seagate Barracuda 7200.10 ST3250620AS 250GB Serial ATA (3.0Gb/s) hard disk. One system has a P965 Neo and the other has a PN6 SLI motherboard. I am having issues in that the OS seems to install properly but after a few days

  • I am looking for what type/setup of Read/Write command in RSLogix 5000 to be used with the NI Ethernet I/P Driver

    I am working on trying to get LabView to communicate with an Allen-Bradley Compact Logix PLC using the NI Ethernet I/P driver.  I am currently getting errors on both system of a CIP Message instruction error and cannot determine if the problem is in

  • Using css in portlets

    Hello I'm writing a portlet that are using a webservice to fetch news from an external source. I want the portlet to render itself using the same style that are aplied on the portal page it is laying on. Is there any api that i can use to get the rig

  • Ae/Ps .psd workflow

    Hi. I'm somewhat new to Ae and am starting to comp some of my shots for my stop-motion film. A lot of the shots will require set extensions and I was wondering if I could use layers that are .psds and import them in a way that when I update the .psd

  • How should SATA drive appear, in UDMA terms?

    Hello all. I've got a Seagate 7200.7 on the Intel controller of my board, which under Device manager in XP shows up as UDMA 5.   Sisoft Sandra 2004 complains that it should be UDMA 6. I don't know what to expect from the SATA interface, and the Seaga