2019-07-27
MySQL - GROUP_CONCAT Permanent Server Limit Setting Change
SET PERSIST_ONLY group_concat_max_len = 1000000;
2019-07-05
Meteor - Javascript template keyup debounce
Template.TEMPLATE_NAME_HERE.events({
'keyup JQUERY_SELECTOR_HERE': _.debounce(function (evt, tmpl) {
return evt.currentTarget.value;;
}, 300)
});
'keyup JQUERY_SELECTOR_HERE': _.debounce(function (evt, tmpl) {
return evt.currentTarget.value;;
}, 300)
});
2019-07-03
TSQL - Delete a job if it exists
IF EXISTS(
SELECT 1
FROM [msdb].[dbo].[sysjobs] a WITH(NOLOCK)
WHERE a.Name = 'JOB_NAME_HERE'
)
EXEC sp_delete_job @job_name='JOB_NAME_HERE',
@delete_unused_schedule=1;
TSQL - Replace carriage returns
SELECT REPLACE(REPLACE(@VARIABLE_OR_FIELD_NAME, CHAR(13), ''), CHAR(10), '');
TSQL - Try and catch and raise error
-- Declarations
declare @error_message nvarchar(2000);
set @error_message = null;
declare @error_severity nvarchar(2000);
set @error_severity = null;
declare @error_state nvarchar(2000);
set @error_state = null;
declare @error_number int;
set @error_number = null;
-- Try
BEGIN TRY
-- Do something here
END TRY
-- Catch
BEGIN CATCH
-- Available error
variables
/*SELECT
ERROR_NUMBER()
,
ERROR_SEVERITY()
,
ERROR_STATE()
,
ERROR_PROCEDURE()
,
ERROR_LINE()
,
ERROR_MESSAGE()
;
*/
-- Error number
set @error_number = ERROR_NUMBER();
-- Capture the error
message, severity and state
set @error_message = ERROR_MESSAGE();
set @error_severity = ERROR_SEVERITY();
set @error_state = ERROR_STATE();
-- Debug
print 'ERROR CAUGHT -> ' + @error_message;
-- Raise error, so the
job that will call this procedure launches a notification
RAISERROR (
@error_message, -- Message text.
@error_severity, -- Severity.
@error_state
--
State.
);
END CATCH
2019-07-02
TSQL - Pass the result of executed dynamic SQL to a variable
DECLARE @sql nvarchar(max);
declare @result int;
SET @sql = 'SELECT @x = COUNT(*) FROM SCHEMA_NAME.TABLE_NAME;';
EXECUTE sp_executesql @sql, N'@cnt int OUTPUT', @x=@result OUTPUT;
print @result;
declare @result int;
SET @sql = 'SELECT @x = COUNT(*) FROM SCHEMA_NAME.TABLE_NAME;';
EXECUTE sp_executesql @sql, N'@cnt int OUTPUT', @x=@result OUTPUT;
print @result;
Subscribe to:
Posts (Atom)