I'm not sure if I should create a View, Stored Procedure, or function for this, but here is what I have so far:
USE [HomeStorageQA2]
GO
DECLARE @SearchValue Varchar(255)
DEClare @Flag Varchar(255)
SET @Flag = NULL
SET @SearchValue = 'Inner point(s) > outer point(s);'
Declare @MainString Varchar(255)
Set @MainString = dbo.GetComments
if Charindex(@SearchValue,@MainString) > 0
begin
Set @Flag = 'True'
end
Select 'Flag' = @Flag
go
If I Set @MainString = [Some value containing SearchValue] , then the query returns True.
I want to use this query for the rows in TestComments.Comments; so it's comparing the value of Comments to the @SearchValue, and returning True or False for each row.
I already have a Stored Procedure dbo.GetComments to find a match via an identifier called SummaryID in the TestComments table.
My final goal is to be able to create a Select statement with three columns of data:
SummaryID,Comments, and the corresponding@Flagvalue for all rows inTestComments. Will this syntax be able to create what I need, and how do I set@MainStringto the value I want?Should this be created as a stored procedure, function, or view? (I'm assuming Stored Procedure or Function)