Solved

how to substring based on the first instance of a character

Posted on 2013-12-31
2
248 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now