DECLARE @TestString varchar(MAX)
SET @TestString = 'WHERE [DeptID] = @[User::DeptID] Or ( [Status] = @[User::Married] And [BirthDate] > @[User::DOB] ) Or [DOB] Is Not Null'
--In @TestString, there could be any # of user parameters in the format @[User::NameOfParam] where NameOfParam is a varaible
I need to update this field to:
'WHERE [DeptID] = @DeptID Or ( [Status] = @Married And [BirthDate] > @DOB ) Or [DOB] Is Not Null'
--Thus only the first ']' immediately after any recurring pattern '[User::' should be eliminated