• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 933
  • Last Modified:

CAST varchar field into INT

I need to CAST a varchar field (Product Number)  that has product numbers that always start with a "BP_some number" into an INT for just the numeric part. For example, if I have the product number BP_4361, I need to CAST this so that I have 4361 as a resulting INT.
Hope this makes sense.
Best regards,
W Delaney
0
wdelaney05
Asked:
wdelaney05
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
select cast ( substring ( product_number , 4, 20 ) as int )
from yourtable
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
SELECT SUBSTRING('ColumnName', CHARINDEX('_','ColumnName')+1,LEN('ColumnName'))
FROM urTable
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now