DECLARE @_strSql NVARCHAR(4000)
SET @_strSqlSub1 =' AND ['+@SelectedType
+'] Like ''%'+@SelectedTypeValue+'%'''
SET @_StrSqlSub2 =' AND MachineRegist_ID = '
+''''+@MachineRegist_ID+''''
SET @_StrSqlSub4 =' AND Time >= '
+''''+@StartDate+''''
SET @_StrSqlSub5 =' AND Time <= '
+''''+@EndDate+''''
SET @_strSql= '
Select *
FROM v_Regist
WHERE 1=1
'
+ CASE @SelectedTypeValue
WHEN ' ' THEN ' '
ELSE @_strSqlSub1
END
EXEC SP_EXECUTESQL @_strSql