SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




CRM Companies List
Web Based CRM Software


Create Unique Identifier on SAP HANA Database using SQLScript


SQL programmers frequently require to generate or create unique string values like unique identifiers also on SAP HANA database using SQLScript. It is possible to create a unique identifier using SQLScript functions NEWUID or SYSUUID. In this HANA database tutorial I want to show examples how SQL developers can use NEWUID function or SYSUUID function to create unique string values.


SAP HANA SQLScript NEWUID Function

SQLScript NEWUID function creates a unique identifier within a specific SAP HANA database. The return type of HANA database NEWUID() function is varbinary(16). SQLScript programmers can use NEWUID SQL function for obtaining unique string which includes alphanumeric (aka alphameric) characters in it which cannot be generated once more on current HANA database using SQLScript function NEWUID.

Please check following SQL codes how you can use NEWUID output.

SELECT NEWUID() FROM DUMMY;

create unique identifier using HANA SQLScript NEWUID function

It is also possible to read unique identifier generated with NEWUID() function and store into a variable and then use it as follows in SQLScript codes.

do
begin

declare UNIQUEIDENTIFIER varchar(100);
select NEWUID() INTO "UNIQUEIDENTIFIER" from dummy;
select :UNIQUEIDENTIFIER from dummy;

end;

generate unique identifiers using SQL NEWUID function


SAP HANA SQLScript SYSUUID Function

Another option for database developer is to use SYSUUID function to generate unique identifier which is universally unique in that HANA instance. This is a broader uniqueness for the created unique identifier with SYSUUID function than NEWUID function which provides uniqueness in a specific database.

SYSUUID name stands for universally unique identifier.
Here is a sample SQL code block where I called SYSUUID function twice. It is interesting to see the difference and mostly the similarity between generated unique identifier values.

do
begin

declare UNIQUEIDENTIFIER varbinary(16);
select SYSUUID into "UNIQUEIDENTIFIER" from dummy;
select :UNIQUEIDENTIFIER as UniqueIdentifier, SYSUUID as AnOther from dummy;

end;

unique identifier generation with sysuuid and newuid SQLScript functions on SAP HANA database






SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table








Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems