• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 584
  • Last Modified:

Built-in Function Determinism

"You cannot influence the determinism of any built-in function. Each built-in function is deterministic or nondeterministic based on how the function is implemented by SQL Server.
For example:
The CAST function is deterministic unless used with datetime, smalldatetime, or sql_variant. "

Please, experts
could help me with transact sql code in order to make this example: The CAST function is deterministic unless used with datetime

0
enrique_aeo
Asked:
enrique_aeo
  • 3
2 Solutions
 
Kevin CrossChief Technology OfficerCommented:
Is this for homework OR are you just wanting to know what an example :

select CAST(GETDATE() AS VARCHAR(20));

so many factors will go into how and what is displayed to you, versus you know what you are getting when you say:

select CAST(1 AS CHAR(1));
0
 
mustaccioCommented:
A deterministic function always return the same result given the same input. A non-deterministic function may sometimes return a different result, given the same input. For example, a datetime formatted with the short (2-digit) year may change over time, depending on how the cut-off year is configured, or if that configuration changes.
0
 
Kevin CrossChief Technology OfficerCommented:
Welcome to Experts Exchange, @mustaccio! Well said.
0
 
enrique_aeoAuthor Commented:
I am studing for certification
0
 
Kevin CrossChief Technology OfficerCommented:
Got you. Just figured if it is something like that you are going to want deeper explanation. Glad we could help.

Best regards,
Kevin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now