Answered by:
Any function similar to sessiontimezone of Oracle

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 @TimeZonePlease click "Mark As Answer" if my post helped. Tony C.
- Proposed as answer by Ricardo Lacerda Monday, September 12, 2016 5:50 PM
- Marked as answer by Sam ZhaMicrosoft contingent staff Friday, September 23, 2016 6:53 AM
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
- Proposed as answer by Albert_ Zhang Friday, September 23, 2016 5:08 AM
- Marked as answer by Sam ZhaMicrosoft contingent staff Friday, September 23, 2016 6:53 AM
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 @TimeZonePlease click "Mark As Answer" if my post helped. Tony C.
- Proposed as answer by Ricardo Lacerda Monday, September 12, 2016 5:50 PM
- Marked as answer by Sam ZhaMicrosoft contingent staff Friday, September 23, 2016 6:53 AM
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
- Proposed as answer by Albert_ Zhang Friday, September 23, 2016 5:08 AM
- Marked as answer by Sam ZhaMicrosoft contingent staff Friday, September 23, 2016 6:53 AM
Monday, September 12, 2016 4:28 PM