oh, ha, lol
ok so this is modified as I need the other fields to display and not sure how to add a WHERE clause?
I need to limit to be able to sort by the extrapolated SalesOrder to >= A*?
select *
from SY_ActivityLog
select LogDate, CompanyCode, ModuleCode, logdescription
,replace(substring(logdescription
,charindex('Item ',logdescription)+5
,charindex(' '
,logdescription+' '
,charindex('Item ',logdescription)+5
)
-charindex('Item ',logdescription)-5
)
,','
,''
)
as item
,replace(substring(logdescription
,charindex('Invoice ',logdescription)+8
,charindex(' '
,logdescription+' '
,charindex('Invoice ',logdescription)+8
)
-charindex('Invoice ',logdescription)-8
)
,','
,''
)
as invoice
,replace(substring(logdescription
,charindex('Sales Order ',logdescription)+12
,charindex(' '
,logdescription+' '
,charindex('Sales Order ',logdescription)+12
)
-charindex('Sales Order ',logdescription)-12
)
,','
,''
)
as salesorder
from sy_activitylog
;
This was my original SQL to view the Log
SELECT [LogDate]
,[LogTime]
,[CompanyCode]
,[UserLogon]
,[ModuleCode]
,[LogDescription]
FROM [MAS_SYSTEM].[dbo].[SY_ActivityLog]
where [LogDate] >='5/13/2018' and ModuleCode = 'S/O'
order by [LogTime] desc
Also getting this Message:
(517273 rows affected)
Msg 537, Level 16, State 2, Line 3
Invalid length parameter passed to the LEFT or SUBSTRING function.