• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

What is the easiest way to test if a target string 'ABC' is in the source string @sourceString?

What is the easiest way to test if a target string 'ABC' is in the source string @sourceString?

This is for SQL 2005
0
chuang4630
Asked:
chuang4630
  • 2
  • 2
1 Solution
 
appariCommented:

if @sourceString like '%ABC%'
   select 'target exists in source'
else
   select 'target not exists in source'
0
 
appariCommented:
if you want to use it in where clause of select/update/delete commands use it like

select * from yourtablename
where sourceColumn like '%ABC%'
0
 
chuang4630Author Commented:
SQL gives me the error at this line

if (@PONumber like '%-PF-%')

0
 
chuang4630Author Commented:
I got it. Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now