- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRaiserrorTimestamp.sql
More file actions
Latest commit
24 lines (17 loc) · 644 Bytes
/
Copy pathRaiserrorTimestamp.sql
File metadata and controls
24 lines (17 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
Description
RAISERROR message with ISO-8601 timestamp.
Can be used inside batch block to give status.
*/
DECLARE @_start datetime2=SYSDATETIME();
DECLARE @_msg nvarchar(2047) =CONVERT(nchar(23), GETUTCDATE(), 126) +N'Z : Get ready...';
RAISERROR(@_msg, 0,0) WITHNOWAIT;
WAITFORDELAY'00:00:04'; -- 4 seconds
DECLARE @_finish datetime2=SYSDATETIME();
DECLARE @_duration int=DATEDIFF(ms, @_start, @_finish);
SET @_msg =N'Finish after %i ms.';
RAISERROR(@_msg, 0,0, @_duration) WITHNOWAIT;
GO
DECLARE @_msg nvarchar(2047) =CONVERT(nchar(23), GETUTCDATE(), 126) +N'Z : 2nd run...';
RAISERROR(@_msg, 0,0) WITHNOWAIT;
GO