Search for columnName and Split data based on that column name

Hi All,
I have a table with one column, lets say Notes of datatype varchar(max).
Source Date:
Notes
ABC:123:XYZ Dept:IT NameID:1 Name:Tom Hummer Date:04/12/2004
456789:CDEF:ADEF
CBD:12/12/2000:ZXCV Dept:HR NameID:1 Name:Sam Dope Date:06/17/2005
I want Output should look like below. It should split data at 'Dept:' and 'Name:' I need SQl code  for SQL Server 2008 R2
Output:
Notes
Dept:IT Name:Tom Hummer
Dept:HR Name:Sam Dope
Thanks,
RH
sql

Hello,
Please refer to the following statements:
create table notes (note varchar(max));
insert into notes values
('ABC:123:XYZ Dept:IT NameID:1 Name:Tom Hummer Date:04/12/2004'),
('456789:CDEF:ADEF'),
('7890:RST:QWER Dept:Sales NameID:2 Name:Mike Kule'),
('CBD:12/12/2000:ZXCV Dept:HR NameID:1 Name:Sam Dope Date:06/17/2005')
select case
when charindex('Name:',note)>0 and charindex('Date:',note)>0
then SUBSTRING(note,charindex('Name:',note)-1,charindex('Date:',note)-charindex('Name:',note))
when charindex('Name:',note)>0 and charindex('Date:',note)=0
then SUBSTRING(note,charindex('Name:',note)-1,len(note)-charindex('Name:',note))
end as name
from notes
where charindex('Name:',note)>0
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support

Similar Messages

  • 8.0.2 - problem 1 - unable to scroll screen when the keyboard is present. Huge problem for emails and other cloud based providers that allow for data entry. We need a fix ASAP!

    8.0.2 - problem 1 - unable to scroll screen down or up when the keyboard is present. When typing text, I am unable to see the text I am writing due to this problem. Huge problem for emails and other cloud based providers that allow for data text entry. While the keyboard is present, I am unable to scroll down to see the text, the screen automatically scrolls back up to the top of the screen. We need a fix ASAP!

    Have you tried resetting your iPad? You will not lose any data. Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Searching for pictures by both date and keyword

    When I have the calendar tab up and a date with pictures is highlighted, when I go to select a keyword the calendar goes away and then I am back to my library. How do I search for pictures by both date and keyword?
    Thank You, Margaret

    Margaret:
    You can use a Smart Album to do the job. Just use the criteria:
    Keyword is "xxxx" and Date is "dd/mm/yyyy"
    Be sure to select All in the Match menu.
    Or you can use the text find box at the bottom in this undocumented way:
    1 - click on the library icon and in the text box type any character.
    2 - select the library icon again and type Command-I
    3 - in the Find window (the same as what you get for a Smart Album) set your criteria: Keyword is "xxx" and Date is "dd/mm/yyyy" and set "All" as the Match criteria.
    4 - hit the search button and those pictures will show up in the thumbnail window.
    5 - when complete clear the text box at the bottom of the window to get all of the photos back.
    Either way you'll get those photos with the keyword and particular date.

  • How to split the data based on one column

    Dear All,
    I have the table data like this.
    type quantity revenue_mny count country
    a 10           10          2 India
    a 20          12          3 India
    b 30          15          1 India
    a 35          20          2 US
    b 20          10          1 US
    b 60          15          1 US
    I woulkd like to split the date based on type column.
    For each country, for Type "a" get the sum of revenue count quanity ans same for b
    and all shuld come in on row for each country.
    output should be like
    country revenue_mny(For a) quantity(for a) count(For a) revenue_mny(for b) quantity(for b) count(For b)
    India 22 30 5 15 30 1
    US 20 35 2 25 80 2
    I tried the below query . its not splittng the date for each country in one row.
    select country,
    sum(case when type='a') then revenue_mny else 0 end ) revenue_mny_a,
    sum(case when type='b' then revenue_mny else 0 end ) revenue_mny_b
    sum(case when type='a' then quantity else 0 end) quantity_a,
    sum(case when type='b' then quantity else 0 end) quantity_b from
    test
    group by country
    Please need your helo

    Like this?
    with t as
    select 'a' type, 10 quantity, 10 revenue_mny, 2 cnt, 'India' country from dual union all
    select 'a', 20, 12, 3, 'India' from dual union all
    select 'b', 30, 15, 1, 'India' from dual union all
    select 'a', 35, 20, 2, 'US' from dual union all
    select 'b', 20, 10, 1, 'US' from dual union all
    select 'b', 60, 15, 1, 'US' from dual
    select country,
    sum(case when type='a' then revenue_mny else 0 end ) revenue_mny_a,
    sum(case when type='a' then quantity else 0 end) quantity_a,
    sum(case when type='a' then cnt else 0 end) cnt_a,
    sum(case when type='b' then revenue_mny else 0 end ) revenue_mny_b,
    sum(case when type='b' then quantity else 0 end) quantity_b ,
    sum(case when type='b' then cnt else 0 end) cnt_b
    from t
    group by country;result:
    COUNTRY  REVENUE_MNY_A QUANTITY_A CNT_A REVENUE_MNY_B QUANTITY_B CNT_B
    India    22            30         5     15            30         1
    US       20            35         2     25            80         2Or you can do it with a decode instead of case. The result will be the same:
    with t as
    select 'a' type, 10 quantity, 10 revenue_mny, 2 cnt, 'India' country from dual union all
    select 'a', 20, 12, 3, 'India' from dual union all
    select 'b', 30, 15, 1, 'India' from dual union all
    select 'a', 35, 20, 2, 'US' from dual union all
    select 'b', 20, 10, 1, 'US' from dual union all
    select 'b', 60, 15, 1, 'US' from dual
    select country,
    sum(decode(type,'a',revenue_mny,0)) revenue_mny_a,
    sum(decode(type,'a',quantity,0)) quantity_a,
    sum(decode(type,'a',cnt,0)) cnt_a,
    sum(decode(type,'b',revenue_mny,0)) revenue_mny_b,
    sum(decode(type,'b',quantity,0)) quantity_b,
    sum(decode(type,'b',cnt,0)) cnt_b
    from t
    group by country;(I changed tablename from TEST to T and columnname from COUNT to CNT, because you should not use reserved words as tablename or columnname.)
    Edited by: hm on 09.10.2012 06:17

  • Search for documents using External Data on list content type

    hi,
    say we have clients in an external database, we create the external content type for use in sharepoint 2013
    we create two content types, Quote and Order for use in a library
    we create a document library that uses the above content types
    we then add a column for the external data ( in this case Client Name- but also include ID) , we have the option to copy to content type selected. so now library shows 'Client' and 'Client:ID'
    I believe that column gets added to  list content types based on the 2 document content types.
    so we have list items , which have a document , a content type and a piece of data from the external LOB system.
    now that is fine, works great, however, how do you configure the content search web part to return documents based on the piece of external data - ie client:ID ? or Client Name ?
    I can map the client:ID to one of the Int00 managed properties and crawl etc - but do not see a way to use that to return documents
    any help would be appreciated :)
    thanks
    MrP

    Create a scopr with that in managed properies and then u can get results from  external sources

  • Creating a external content type for Read and Update data from two tables in sqlserver using sharepoint designer

    Hi
    how to create a external content type for  Read and Update data from two tables in  sqlserver using sharepoint designer 2010
    i created a bcs service using centraladministration site
    i have two tables in sqlserver
    1)Employee
    -empno
    -firstname
    -lastname
    2)EmpDepartment
    -empno
    -deptno
    -location
    i want to just create a list to display employee details from two tables
    empid firstname deptno location
    and same time update  in two tables
    adil

    When I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list.  When I attempt to edit it, I get an error:
    External List fails when attached to a SQL view        
    Sorry, something went wrong
    Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
    I can edit the view in SQL Manager, so it seems strange that it fails.
    Any advice would be greatly GREATLY appreciated. 
    Thanks,
    Randy

  • Music Player continuously searching for songs and ...

    I have a N97 running firmware v.21.0.045 and about a week or so ago I was forced to do the hard reset because the phone became so unstable. I left my E: drive (the mass storage) intact including all of my songs, videos and pictures I had stored.
    Everything seems to be okay apart from the Music Player which everytime I use it it starts to search for songs and podcasts continuously. I can stop that and it lists all of my music and can play them but the volume control does not work, either from the telephone or the earpiece supplied.
    I have tried leaving it searching for hours but nothing changes - it just keeps on searching. Any suggestions as to how I can fix this please or does it mean I have to do another reset of the telephone? It all worked before.
    I have tried taking the battery out but this makes no difference.

    This is the solution
    ok i found the solution here by deleting the corrupted library
    http://portablevideo.blogspot.com/2008/12/music-player-database-problems.html 
    now one of these below is for the music and one for the photos and i didnt have a problem with the photos but did it anyways and now the player can see my music:
    these are the files that need deleting in order to get rid of the corrupted library.
    Storage Drives: (Mass storage E, Memory Card F)
    \private\101ffca9\harvesterdbvx_x.dat
    \private\10281e17\[string]mpxvx_x.db
    \private\10281e17\[string]pcvx_x.db 
    TIP: Connect the device in USB mass storage mode (File Transfer), to locate the private folder from the PC.
    TIP: STRING and x_x will change depending on your phone. (my files had slightly different names than above on the n97
    Kudos to diginoise and Google, I've used it and it works, so have many others, as I've poted this a few times
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • App for making And splitting audio recording (iphone 4)

    Is there a good app for making AND splitting an audio recording?
    I just want an app that I can use at work to record meetings and interviews.
    And when I am done listening to half of a track, I want to be able to split it and delete the first half.
    A search of the web was not useful.
    Any recommendations?
    Thanks.
    mac

    Hi,
    It is possible to limit the app to specific device features. For example if you require camera access or better graphics support, you can use UIRequiredDeviceCapabilities and add it to your -app.xml file.
    Here's info on what values you can set for this key: http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyRefere nce/Articles/iPhoneOSKeys.html
    Within the -app.xml file there is a tag called <iPhone> and inside there is another called <InfoAdditions> There you see where it sets the value for UIDeviceFamily. Below the UIDeviceFamily tag you can add the UIRequiredDeviceCapabilities tag.
    For example if you require front camera support you would add:
    <key>UIRequiredDeviceCapabilities</key>
    <dict>
         <key>front-facing-camera</key>
         <true/>
    </dict>
    Note that when you edit the -app.xml file, it may be overwritten if you use something like Flash CS5 extension where it updates the file when you change values in the iOS properties panel.
    Good luck,
    iBrent

  • I have problem with my wifi in 4 S, i cant connect to any wifi itried resetting network setting and reset all setting but the result was the same, its only keeps searching for wifi and cant find any, itried to use OTHER but also didnt work.please help me

    i have problem with my wifi in 4 S, i cant connect to any wifi itried resetting network setting and reset all setting but the result was the same, its only keeps searching for wifi and cant find any, itried to use OTHER but also didnt work.please help me???

    If Join was on then your home wi-fi must be set to Non-Broadcast.  If you did not set this up (maybe your provider did) then you will need to find the Network Name they used, and any password they used.  The SSID is Security Set ID and to see more try http://en.wikipedia.org/wiki/SSID .  Basically it is the name used to identify your router/network.  A lot of times the installer will leave it set as LinkSys, or Broadcom or whatever the manufacturer set it as for default.  Your best bet is to get whoever installed it to walk you through how they set it up, giving you id's and passwords so you can get in.  HOWEVER, if you are not comfortable with this (if you set security wrong, etc.) you would be well ahead of the game to hire a local computer tech (networking) to get this working for you.  You can also contact the vendor of your router and get help (if it is still in warranty), or at least get copies of the manuals as pdf files.  Sorry I can't give you more help, I hope this gives you an idea where to go from here to find more.

  • Windows Server 2003 R2 Enterprise Edition 32 bits Service Pack 2 never finishes searching for updates and use 100% of CPU.

    Hi everyone, I am having issues updating a clean Windows Server 2003 R2 Enterprise Edition 32 bits Service Pack 2, so any help with be appreciated cause I've already tried all my cards for the past 5 days in this particular issue without success.
    All I did so far is installing Windows Server 2003 R2 Enterprise with Service Pack 2, open IE to update, it keeps searching for updates and never stop, after 20mn to 30mn the process svchost.exe start using 100% of my CPU.
    I already tried the following scenarios:
    1-  Install IE8, install the update KB927891 and the Windows Update Agent 3.0 (I already had this one installed). Reboot and run windows update trough IE8 and the problem did not solved.
    2- Install those 2 software "MicrosoftFixit.wu.MATSKB.Run" and "MicrosoftFixit50777", open IE to update, it still hangs and continues eating my CPU. This is the output of "MicrosoftFixit".
    Windows Update error 0x8007000D(2014-01-06-T-06_06_34A) --> Not Fixed
    Cryptographic service components are not registered (This service is actually running successfully) --> Not Fixed
    3- I found the following script that would register some DLL, deleting the "SoftwareDistribution" and forcing windows update to solve the problem and nothing happened either.
    Link to script:
    http://gallery.technet.microsoft.com/scriptcenter/Dos-Command-Line-Batch-to-fb07b159#content
    Here is a link to the content of my WindowUpdate.log file:
    https://skydrive.live.com/redir?resid=883EE9BE85F9632B%21105
    Thank you in advance for helping.

    All I did so far is installing Windows Server 2003 R2 Enterprise with Service Pack 2, open IE to update, it keeps searching for updates and never stop, after 20mn to 30mn the process svchost.exe start using 100% of my CPU.
    Herein is the root cause of your issue. A topic that's been discussed in several blogs, forums, and even in the media since September regards a known issue with attempting to patch IE6 RTM via Windows Update.
    Aside from that particular issue... browsing the Internet with an unpatched instance of IE6, especially from a Windows Server system, is also asking for a world of hurt.
    Might I suggest the following:
    Download the IE8 for Windows Server 2003 installer to a thumb drive.
    Download the latest Cumulative Security Update for IE8 for Windows Server 2003 to a thumb drive.
    Reinstall Windows Server 2003 with Service Pack 2.
    Upgrade to IE8 from the thumb drive installer and apply the
    Cumulative Security Update.
    Now your machine is capable of safely browsing to Windows Update to install the rest of the updates (well, maybe, there's also all those other Security Updates from the past seven years that your machine still has vulnerabilites for -- even those seven
    years of updates are going to take a Very Long Time to scan for, download, and install).
    Why don't you have a WSUS server? -- noting, wryly, that you've posted in the *WSUS* forum.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • My iphone 3g is keep searching for network, and the carrier unable to load network list , wat shall i do?  Read more: My iphone 3g is keep searching for network, and the carrier unable to load network list

    My iphone 3g is keep searching for network, and the carrier unable to load network list , wat shall i do?

    Yes, that kind of tallies with my experience ... after 3 days of useless iPhone 3G (BTW, killing 3G on the phone and relying on acquiring AT&T 2G didn't help, it still locked onto T-Mobile with the result that it was draining battery and rebooting frequently!), I ended up visiting the local Apple Store.
    Although the visit was not to resolve the iPhone problem, whilst there I happened to cycle the phone and due to the store having a local AT&T cell, the strength of the local signal meant that I finally re-acquired a AT&T 3G signal ... once locked on again the phone was fine for the next day.
    Nett outcome of this is that I would prefer to lay most of the blame for this debacle on the poor state of 3G support both by AT&T (and US carriers in general), maybe exacerbated in my case by two related events (the local DNC in Denver, which saturated local AT&T cells including 3G and a proliferation of v2.0.0 and v2.0.1 firmwares on iPhones in town, which dragged cell coverage into the weeds).
    It would be nice for future sanity if AT&T and T-Mobile could at least resolve the ability to acquire/release the iPhone gracefully, otherwise I'll be very sceptical of travelling back to the US with only my iPhone, as a self-employeed consultant I can't afford to be out of touch for three days again!

  • When I try to print from my iPad I see a message "searching for printer" and then "no printer found.".  I have a printer application loaded and it finds my wireless printer.   How do I get the iPad to do the same so I can print from emails, the web, etc?

    When I try to print from my iPad I see a message "searching for printer" and then "no printer found.".  I have a printer application loaded and it finds my wireless printer.   How do I get the iPad to do the same so I can print from emails, the web, etc?  Thanks

    sandrafromsilver spring wrote:
    When I try to print from my iPad I see a message "searching for printer" and then "no printer found.".  I have a printer application loaded and it finds my wireless printer.   How do I get the iPad to do the same so I can print from emails, the web, etc?  Thanks
    Go to the following link:
    http://jaxov.com/2010/11/how-to-enable-airprint-service-on-mac-os-x-10-6-5/

  • Best practice for Plan and actual data

    Hello, what is the best practice for Plan and actual data?  should they both be in the same app or different?
    Thanks.

    Hi Zack,
    It will be easier for you to maintain the data in a single application. Every application needs to have the category dimension, mandatorily. So, you can use this dimension to maintain the actual and plan data.
    Hope this helps.

  • Wen I turn on the my macbook it only show the aple icon and it show like it looding sometink or searching for someting and it never open.

    wen I turn on the my macbook it only show the aple icon and it show like it looding sometink or searching for someting and it never open.

    May need to grab a micro usb cable and restore via iTunes
    http://support.apple.com/kb/HT4367

  • Please help me. My YouTube app will not work. Every time I open it says 'cannot connect to youtube'. I have searched for help and tried resetting my settings and rebooting my ipad2 but nothing has solved the issue.

    Please help me. My YouTube app will not work. Every time I open it says 'cannot connect to youtube'. I have searched for help and tried resetting my settings and rebooting my ipad2 but nothing has solved the issue.

    Yes, I am connected to the Internet through my wifi. Everything is working fine with the e  eption of youtube.  I have reset all Internet settings and have tried synching to iTunes followed by rebooting.  This is all the advice I have found although none of it has been helpful.
    Has anyone else encountered this problem?

Maybe you are looking for

  • How to get all the values of a variable with F4 with checkboxes to select

    Dear Experts, After Executing a query by giving let 3 values(Out of 10 Values) to a variable. To give 2 more input values to the same variable(i.e.,total I wanted to give 5 inputs this time ),after refreshing the query,for that variable if I click F4

  • Smart objects rendering incorrectly

    Whenever I paste an object from illustrator as a smart object the edges become jagged and the vector loses it's sharpness. It works fine in CS6 but this hads just started happening in Photoshop CC. I've updated to the current version but it hasn't ch

  • Setting a response header in a CQ5 publishing instance

    I want to disable caching in a CQ component and I have the following line in my jsp (documentation): response.setHeader("Dispatcher", "no-cache"); If I insert the component in a page and load the page in an authoring instance everything works as expe

  • Campaign Code-CRM 2007

    Hi Experts, I need to generate Campaign Code in Campaign.Modified component CPGOE_DETAILS and added the field campaign code but it is appearing in non editable mode.Please help. Thanks & Regards, Moumita Rana

  • Parental Controls on E2000

    Hi, I have been trying to set parental controls for my kids. I only want to set parental controls on the weekdays. I've noticed that the option to disable it on the weekends is not available. Once I select "specific time".. the weekends tab enables a