viernes, 26 de junio de 2015

Search String on Multiples Stored Procedures

The goal is search the '***' string, including single comma.

SELECT OBJECT_NAME(object_id)
FROM sys.sql_modules
WHERE OBJECTPROPERTY(object_id, 'IsProcedure') = 1 AND definition LIKE '%''***''%';

martes, 9 de junio de 2015

Get the lastest 10 records from a Log Table

Here an example of getting the lastest 10 records from a log table.

DECLARE @Rows SMALLINT = 10
DECLARE @logid VARCHAR(10) = 'APP.BANCO'

SELECT [LogId],[Process],[CreatedOn],[Type],[Message]
FROM [dbo].[LogApplication]
WHERE [Process] = @logid
ORDER BY LogId DESC OFFSET 0 ROWS FETCH NEXT @Rows ROWS ONLY