dbTalk Databases Forums  

Re: Computed PERSISTED column for dates that tests for valid date:How To

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Re: Computed PERSISTED column for dates that tests for valid date:How To in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
--CELKO--
 
Posts: n/a

Default Re: Computed PERSISTED column for dates that tests for valid date:How To - 11-03-2009 , 07:29 AM






One solution I used was a look up tale with one DATE column and a
bunch of string columns to hold various "local dialect" dates. Scrub
up the raw data a little bit and do string matches.

It was easy to fill in with a spreadsheet that had options. The nice
part was that an ambiguous date (mm-dd versus dd-mm) was easy to
find. 20 years was more than enough for my purposes.

Reply With Quote
  #2  
Old   
bill
 
Posts: n/a

Default Re: Computed PERSISTED column for dates that tests for valid date:How To - 11-03-2009 , 06:22 PM






That's a great idea, and I actually already tried it. It is fast, and
makes intuitive sense, which is always a plus to me.

The problem is that I want to have the lookup fire as part of a
computed persisted column.

I don't like persisting derved data, but it makes sense in this case,
because it's a write-once read-many situation. Given that it is going
to be persisted, the choice is between a persisted computed column and
a trigger, and I like the computed column much better.

Since the computed column has to be some kind of function, I just
wrote a simple function (generally not a fan of scalar functions, but
in this case, it seemed a good solution) that looks up the date and
returns it. Problem, this function is non-deterministic, so I can't
use it in a PERSISTED column.

I'm amazed that MSFT doesn't allow one to supply the format string for
ISDATE, and thus make it deterministic.

Thanks,

Bill

On Nov 3, 5:29*am, --CELKO-- <jcelko... (AT) earthlink (DOT) net> wrote:
> One solution I used was a look up tale with one DATE ...

Reply With Quote
  #3  
Old   
--CELKO--
 
Posts: n/a

Default Re: Computed PERSISTED column for dates that tests for valid date:How To - 11-03-2009 , 06:59 PM



Quote:
I'm amazed that MSFT doesn't allow one to supply the format string for ISDATE, and thus make it deterministic.
If they would come up to ANSI/ISO Standards then the ONLY format would
be yyyy-mm-dd. The new DATE data type might do that

Reply With Quote
  #4  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: Computed PERSISTED column for dates that tests for valid date: How To - 11-04-2009 , 02:56 PM



On Tue, 3 Nov 2009 16:22:22 -0800 (PST), bill wrote:

Quote:
I don't like persisting derved data, but it makes sense in this case,
because it's a write-once read-many situation. Given that it is going
to be persisted, the choice is between a persisted computed column and
a trigger, and I like the computed column much better.
Hi Bill,

Have you considered using a materialized view, as a third alternative?

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.