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

x
?
Solved

sql FIELD CONVERT (SHORTEN)

Posted on 2011-09-14
3
Medium Priority
?
304 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

596 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