Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Conversion failed when converting the varchar valu

Author  Topic 

irfunme
Starting Member

1 Post

Posted - 2011-08-01 : 11:11:46
Hello everyone, This is the first time I registerd to a SQL Server forum and here is my first question.

I have a column(XYZ) which is varchar dataype and I need to get only those records which have only nuermic characters in XYZ column by comparing the numeric range. I tried following query but getting conversion error.

SELECT *
FROM
(
SELECT *
FROM [TABLE] T
WHERE patindex('%[a-zA-Z]%',T.[XYZ]) = 0
) A
WHERE CAST(A.[XYZ] AS INT) > 00100
AND CAST(A.[XYZ] AS INT) < 01999

The sub select is to get only those records which have only numeric characters in XYZ column and main select statement is to get from the above mentioned range.

If anyone can help me here would very helpful.

Thanks
irfan

lappin
Posting Yak Master

182 Posts

Posted - 2011-08-01 : 11:29:57
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=161441
http://www.tek-tips.com/faqs.cfm?fid=6423
Go to Top of Page
   

- Advertisement -