I am trying to find a way to query for a field that only contains a certain data type.

For example, I want to return all values from dbo.tableA.ColumnA that contain a string of '___-___' where each _ is a numeric character. (The - is just a normal dash)

Also, I know this can be done using dynamic queries (which I am not experienced with) and I am aware that those high level queries probably require the creation of temp tables, which is something I can not do because I am only querying a snap-shot, and thus do not have Write access.

I have tried searching my pants off for an answer, with no luck. Please help. Thank you.

有帮助吗?

解决方案

You can use the LIKE operator for this.

SELECT ColumnA 
FROM dbo.tableA
WHERE ColumnA LIKE '%[0-9][0-9][0-9]-[0-9][0-9][0-9]%'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top