Re: Using '_' as a character and not as a wildcard
From: Daniel Crichton (msnews_at_worldofspack.co.uk)
Date: 12/21/04
- Next message: Daniel Crichton: "Re: I found a bug in MSSQL DTS import wizard"
- Previous message: Uri Dimant: "Re: Using '_' as a character and not as a wildcard"
- In reply to: Steen Persson: "Using '_' as a character and not as a wildcard"
- Next in thread: Steen Persson: "Re: Using '_' as a character and not as a wildcard"
- Reply: Steen Persson: "Re: Using '_' as a character and not as a wildcard"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 21 Dec 2004 09:34:57 -0000
"Steen Persson" <SPE@REMOVEdatea.dk> wrote in message
news:%23L5nV0z5EHA.2124@TK2MSFTNGP15.phx.gbl...
> Hi
>
>
> I'm trying to do a script that can automatically backup the databases on
> our
> Datawarehouse server. The databases have been prefixed with 'pl_'.
>
> When I run -
>
> SELECT Catalog_Name
> FROM Information_Schema.Schemata
> WHERE Catalog_Name LIKE 'pl_%'
>
> - it finds all my databases that have been prfixed with 'pl_' but also
> some
> called e.g. 'plan....'.
> I can see in BOL that '_' is seen as a wildcard that can substitute any
> single character, but how do I tell my query to use '_' as a part of the
> name and not as a wildcard?
You can add the ESCAPE clause to tell the query processor to treat the
character after the defined escape character as a literal, ie
SELECT Catalog_Name
FROM Information_Schema.Schemata
WHERE Catalog_Name LIKE 'pl!_%'
ESCAPE '!'
The ! is the escape character in this case, so the _ is interpreted as a
literal character rather than a wildcard.
Dan
- Next message: Daniel Crichton: "Re: I found a bug in MSSQL DTS import wizard"
- Previous message: Uri Dimant: "Re: Using '_' as a character and not as a wildcard"
- In reply to: Steen Persson: "Using '_' as a character and not as a wildcard"
- Next in thread: Steen Persson: "Re: Using '_' as a character and not as a wildcard"
- Reply: Steen Persson: "Re: Using '_' as a character and not as a wildcard"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|