Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

split string in sql

Posted on 2013-01-14
3
Medium Priority
?
414 Views
Last Modified: 2013-01-14
How can I split a String at "," if it exists?

lastname, firstname

Doe, john

or it could be just name of a business

Bank of American
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
Emes earned 2000 total points
ID: 38775001
declare @names varchar(100)
set @names ='My,Name'


if charindex(',', @names) <> 0
  Select substring(@names,1, charindex(',', @names) -1),
    substring(@names, charindex(',', @names) +1,100)
0
 

Author Comment

by:VBdotnet2005
ID: 38775039
What if a string does not contain ","?   Bank of American

Command(s) completed successfully.  it does not return anything.
0
 

Author Comment

by:VBdotnet2005
ID: 38775064
I got it. Thank you
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question