locked
Any function similar to sessiontimezone of Oracle RRS feed

  • Question

  • Hello, All

     Recently our customers would like to evaluate and migrate existing Oracle database to SQL Server database.

     When they check sessiontimezone function of Oracle database to return timezone of session, 

     They could not find any similar one to detect and return time zone value to each connected session in SQL Server.

     May I know if there is any suggestion or anything I could try?

     Best regards

    Monday, September 12, 2016 4:17 PM

Answers

  • If you're wanting the name of the Time Zone where the SQL Server Instance is installed then you could use this

    DECLARE @TimeZone VARCHAR(50)
    EXEC MASTER.dbo.xp_regread 'HKEY_LOCAL_MACHINE',
    'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
    'TimeZoneKeyName',@TimeZone OUT
    SELECT @TimeZone


    Please click "Mark As Answer" if my post helped. Tony C.

    Monday, September 12, 2016 4:27 PM
  • You can try:

    select datepart (tz, sysdatetimeoffset())


    Russel Loski, MCSE Data Platform/Business Intelligence Twitter: @sqlmovers; blog: www.sqlmovers.com

    Monday, September 12, 2016 4:28 PM

All replies

  • If you're wanting the name of the Time Zone where the SQL Server Instance is installed then you could use this

    DECLARE @TimeZone VARCHAR(50)
    EXEC MASTER.dbo.xp_regread 'HKEY_LOCAL_MACHINE',
    'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
    'TimeZoneKeyName',@TimeZone OUT
    SELECT @TimeZone


    Please click "Mark As Answer" if my post helped. Tony C.

    Monday, September 12, 2016 4:27 PM
  • You can try:

    select datepart (tz, sysdatetimeoffset())


    Russel Loski, MCSE Data Platform/Business Intelligence Twitter: @sqlmovers; blog: www.sqlmovers.com

    Monday, September 12, 2016 4:28 PM