I've been playing around on a test database today, and one of the things I've done is created a function to retrieve the current Pacific datetime (server is on Mountain).
CREATE FUNCTION [dbo].[fn_get_pst_datetime] (@serverdatetime datetime = NULL)
IF @serverdatetime IS NULL
SET @serverdatetime = getdate()
DECLARE @pstdatetime datetime
SET @pstdatetime = dateadd(hour,(-1),@serverdatetime)
Function seems to work when I call it in queries. But if I include "[dbo].[fn_get_pst_datetime](DEFAULT)" as the default value of any table's datetime fields, the table gets corrupted and I have to delete it and start over.
- Unable to modify table.
A severe error occurred on the current command. The results, if any, should be discarded.
Is my function bad? Did I do something wrong? What's the prob here? Thanks!
"If I had been drinking out of that toilet, I might have been killed."