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