Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pvccaz
Yak Posting Veteran
87 Posts |
Posted - 2011-12-09 : 11:58:45
|
| Hi,I want to find out if a specific variable has a pattern of a value. I will be getting the variable as an input.For example:DECLARE @TESTWORD1 VARCHAR(80)DECLARE @TESTWORD2 VARCHAR(80)DECLARE @TESTWORD3 VARCHAR(80)SET @TESTWORD1 = 'HELLO WORLD'SET @TESTWORD2 = 'HELLO THERE'SET @TESTWORD3 = 'SQL SERVER'I want to check if 'HELLO' is present in @TESTWORD1, @TESTWORD2, @TESTWORD3. The output should be true for @TESTWORD1 and @TESTWORD2 but false for @TESTWORD3 Is there any pattern function that i can use to check a variable?Thanks, |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-09 : 12:19:57
|
| you can use PATINDEX()http://msdn.microsoft.com/en-us/library/ms188395(v=sql.90).aspx------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
pvccaz
Yak Posting Veteran
87 Posts |
Posted - 2011-12-09 : 13:23:41
|
| Thank you !. This works. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-10 : 07:42:20
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|