Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
How t Split last two char from varchar...
How t Split last two char from varchar dataset..?
Rate Topic
Display Mode
Topic Options
Author
Message
bhushan_juare
bhushan_juare
Posted Wednesday, February 13, 2013 1:42 AM
Valued Member
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:14 AM
Points: 62,
Visits: 358
Hi All,
This is the query i have written but unable to extract last two char..
max(CASE CHARINDEX(' ', GT.FG_DESCRIPTION, 1) WHEN 0 THEN GT.FG_DESCRIPTION
ELSE SUBSTRING(GT.FG_DESCRIPTION, 1, CHARINDEX(' ', GT.FG_DESCRIPTION, 1) - 2) END) AS PROD_TYPE
Output coming
A B
14.00-24 32 PR BKT EM937 TL 14.00-2
700/40-22.5 16 PR BKT FLOT648 TL 700/40-22.
30.5L-32 12 PR BKT TR137 TR 30.5L-3
Required Output
A B
14.00-24 32 PR BKT EM937 TL TL
700/40-22.5 16 PR BKT FLOT648 TL TL
30.5L-32 12 PR BKT TR137 TR TR
Thanks
Bhushan
Post #1419339
Cadavre
Cadavre
Posted Wednesday, February 13, 2013 2:52 AM
SSCrazy
Group: General Forum Members
Last Login: Thursday, May 16, 2013 9:16 AM
Points: 2,236,
Visits: 6,486
What does the original data look like? What is the DDL for the table?
Not a DBA, just trying to learn
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better, quicker answers on SQL Server performance related questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
If you litter your database queries with nolock query hints, are you aware of the side effects?
Try reading a few of these links...
(*)
Missing rows with nolock
(*)
Allocation order scans with nolock
(*)
Consistency issues with nolock
(*)
Transient Corruption Errors in SQL Server error log caused by nolock
(*)
Dirty reads, read errors, reading rows twice and missing rows with nolock
LinkedIn
| Blog coming soon (for sufficiently large values of "soon"
)!
Post #1419361
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.