Question

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.

Était-ce utile?

La solution

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]%'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top