December 18, 2020 at 8:56 am
Hi,
I want to list al tables that contains only _ar_ in the name (archive tables)
I have tried the following script
Select name from sys.tables where name like '%_ar_%'
but when i get the result i also see tables like abc_yard_abc and i only want to have tables like abc_ar_abc
December 18, 2020 at 9:33 am
Your problem here is that the underscore character is itself a wildcard in T-SQL, matching any single character. That explains the results you are seeing.
The solution is to ESCAPE the wildcard. Something (rather inelegant) like this (untested):
Select name
from sys.tables
where name like '%|_ar|_%' ESCAPE '|';
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
December 18, 2020 at 9:36 am
Thanks Phil it seems to work !
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply