ict.ken.be

Delivering solid user friendly software solutions since the dawn of time.

GETDATE vs SYSDATETIME 

Categories: SQL Server

The precision of SYSDATETIME is in nanoseconds, the one for GETDATE is in miliseconds.

Just try for yourself

SELECT SYSDATETIME() fn_SysDateTime, GETDATE() fn_GetDate

SQL Insert Or Update AKA Upsert 

Categories: SQL Server

Since MsSQL 2008 you can use the MERGE command for inserting or updating, here is a small example I use with mojoPortal. I call it from a custom PageInitEventHandler and allows me to track what pages a user visits.

CREATE PROCEDURE [dbo].[kenTracking_Pages_Upsert]

@UserGuid	uniqueidentifier,
@SiteGuid	uniqueidentifier,
@PageGuid	uniqueidentifier

AS

SET NOCOUNT, XACT_ABORT ON;

MERGE [dbo].[kenTracking_Pages] WITH (HOLDLOCK) AS target
USING (SELECT @UserGuid, @SiteGuid, @PageGuid) AS source (User_Guid, Site_Guid, Page_Guid)
ON (target.User_Guid = source.User_Guid) AND (target.Site_Guid = source.Site_Guid) AND (target.Page_Guid = source.Page_Guid)
WHEN MATCHED THEN
UPDATE SET Visits = Visits + 1, DateModified = GETDATE()
WHEN NOT MATCHED THEN
INSERT
(
User_Guid,
Site_Guid,
Page_Guid
)
VALUES
(
@UserGuid,
@SiteGuid,
@PageGuid
);

RETURN @@ERROR;
GO

JWT 

Categories: Security

JWT - Json Web Token

  • The claim Names within a JWT must be unique.
  • JWTs with duplicate claim names must be rejected.

Reserved Claim Names

  • "iss" (Issuer) claim: case sensitive string containing a name or uri value.
  • "sub" (Subject) claim: string with principal that is the subject of the JWT.
  • "aud" (Audience) claim: an array of case sensitive strings, each containing a StringOrURI value.
  • "exp" (Expiration Time) claim: value must be an epoch. Use of this claim is OPTIONAL.
  • "nbf" (Not Before) claim: for issuing future tickets. Value is epoch.
  • "iat" (Issued At) claim: the time at which the JWT was issued.
  • "jti" (JWT ID) claim: a unique identifier for the JWT. Can be used to prevent the JWT from being replayed. Case sensitive string.
  • "typ" (Type) claim: to declare a type for the contents of this JWT claims set.

More: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html

Page 20 of 42 << < 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 40 > >>