Wildcard Search

CREATE FUNCTION [dbo].[F_TRANSLATEWILDCARD]
               (@text      VARCHAR(4000))
RETURNS VARCHAR(4000)
AS
  BEGIN
    DECLARE @ReturnValue VARCHAR(4000)

    IF (@text IS NOT NULL AND LEN(@text) > 0)
      BEGIN
         SET @ReturnValue = REPLACE(@text, '[', '[[]')
         SET @ReturnValue = REPLACE(@text, '%', '[%]')
         SET @ReturnValue = REPLACE(@ReturnValue, '_', '[_]')
         SET @ReturnValue = REPLACE(REPLACE(@ReturnValue, '?', '_'), '*', '%')
      END
     
    RETURN @ReturnValue
  END

posted @ 2008-08-25 12:25  RobotTech  阅读(232)  评论(0编辑  收藏  举报