Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VAL() type of function?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00825781
Message ID:
00825790
Views:
29
Would this work for you?
DECLARE @pn varchar(15)
SET @pn = 'FLR-142A'
SELECT 
	CAST(
		CASE WHEN RIGHT(SUBSTRING(@pn, CHARINDEX('-', @pn)+1,15),1) <= '9'
			THEN SUBSTRING(@pn, CHARINDEX('-', @pn)+1,15) ELSE 
				LEFT(SUBSTRING(@pn, CHARINDEX('-', @pn)+1,15), 
LEN(SUBSTRING(@pn, CHARINDEX('-', @pn)+1,15))-1) END 
	AS int)
>Thanks Serg.
>
>select Cast(right(rtrim(pa_page),3) AS int) AS 'value',
>* from deppage
>
>errors on :
>Syntax error converting the varchar value 'O-8' to a column of data type int.
>
>I have lots of Embedded #'s in this column. XXX-NNNX or XX-NN or XXX-NNX
>
>Maybe a union to pull from the 3 NNN #'s as well as the primary 2 NN #'s?
>
>I'm still getting Whacked by the occassional last Letter?
>
>
>__Stephen
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform