Solved

how to substring based on the first instance of a character

Posted on 2013-12-31
2
273 Views
Last Modified: 2014-01-01
I want to substring to get position 13 to the position just before the first semi-colon.

The string is
Data Source=edwdev02; User Name=med_query_user; Server=codenamed;

I want to end up with edwdev02

So something like
Select substring(my_variable,13,instring_position(my_variable,';') - 1)
From such_and_such
Where this_and_that
0
Comment
Question by:Alaska Cowboy
[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 Comments
 
LVL 23

Accepted Solution

by:
Mysidia earned 250 total points
ID: 39749396
Try

SELECT
   CASE WHEN  charindex(';',my_variable, 13)  > 0  
            THEN substring(my_variable,13,charindex(';',my_variable, 13) - 13)
             ELSE  NULL
   END

From such_and_such
Where this_and_that
Go
0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 39749949
Mysidia,

worked ! thanks :-)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

617 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