?
Solved

sql FIELD CONVERT (SHORTEN)

Posted on 2011-09-14
3
Medium Priority
?
301 Views
Last Modified: 2012-05-12
THIS IS PROBABLY SUPER EASY FOR ALL OF YOU.. BUT I'M STILL A NEWBIE AT SQL

i HAVE A COLUMN THAT CONTAINS DATA THAT LOOKS LIKE THIS.

666/WK22Reynolds/Jun 03, 2011/74/1/  

1057/6182011ims/Jun 22, 2011/302/1/1/ 1096-/217000-  -/3

I WANT TO CHANGE IT TO ONLY USE THE THE NUMBERS UP TO THE FIRST '/'

THEREFORE: return would be  

666  
1057
Can you help please?
0
Comment
Question by:Cree
[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
3 Comments
 
LVL 18

Accepted Solution

by:
lludden earned 1000 total points
ID: 36537185
SELECT SUBSTRING(Field1, 1,patindex('%/%',Field1)-1)
0
 
LVL 5

Expert Comment

by:zvytas
ID: 36537200
This will give you data you want, but as a string:

SELECT SUBSTRING(Column, 1, CHARINDEX('/', Column) - 1)

If you need an int, use the following:

SELECT CONVERT(int, SUBSTRING(Column, 1, CHARINDEX('/', Column) - 1))
0
 

Author Closing Comment

by:Cree
ID: 36537208
thanks.. you rock.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Suggested Courses

770 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