Find Database With Numbers In the Name

You might have a need to search across all your databases, and find Databases with ONLY a certain name. Maybe there are numbers in the name, but the number are all different than one another so you can’t just write a query using the LIKE, and provide a wildcard. The best thing you can do is use the PATINDEX to help you get all the Databases that have numbers suffixed on the name.

Lets say you have Databases prefixed with INV, then there are a set of numbers on the end so it looks like this INV#########.

You could write the query like this:

patindex('INV' + '%[0-9]%') > 0
order by
name asc


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s