Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hello,How can we set the Time Zone of a database permenently?It should work regardless of OS Time Zone.Any solution for getting different datatime for two different database instance running on same sql server.Any Solution other than getutcdate() in appreciableRegards,KCube
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-07-30 : 05:30:24
Yes. Write an UDF to return DATETIME.E 12°55'05.25"N 56°04'39.16"
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-07-30 : 05:34:09
[code]CREATE FUNCTION dbo.fnMyTimeZone( @DbName SYSNAME)RETURNS DATETIMEASBEGIN RETURN CASE @DbName WHEN 'Db1' THEN DATEADD(HOUR, -1, GETDATE()) WHEN 'Db2' THEN DATEADD(HOUR, -3, GETDATE()) ELSE GETDATE() ENDEND[/code]Call with SELECT dbo.fnMyTimeZone(DB_NAME())E 12°55'05.25"N 56°04'39.16"
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-07-30 : 05:35:19
Or per server maybe?
CREATE FUNCTION dbo.fnMyTimeZone()RETURNS DATETIMEASBEGIN RETURN CASE @@SERVERNAME WHEN 'Server1' THEN DATEADD(HOUR, -1, GETDATE()) WHEN 'Server2' THEN DATEADD(HOUR, -3, GETDATE()) ELSE GETDATE() ENDEND
E 12°55'05.25"N 56°04'39.16"
KCube
Starting Member
2 Posts
Posted - 2008-07-30 : 23:13:42
Hi,Thanks very much for the effort. Will it be over burden for the server. Will it affect the performance.Is there any difference between UDF and buitin function in respect to performance.I am concern about the performace issues.
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-07-31 : 04:31:32
Not much, since the function is written as an inline-function.E 12°55'05.25"N 56°04'39.16"