Solved

SQL function

Posted on 2014-11-21
3
210 Views
Last Modified: 2014-11-21
Hi
I have 2 functions and not sure what it does and why structured this way.

Fun_a:

Create function x()
Return table
As
Return
(Select distinct ID from fun_b(getdate()) as result)
Go

Fun_b:
Create function fun_b(@asifdate datetime)
Return table
As
Return
(
Select distinct cc as ID
 ( select a,s,f from tbl
Where year = '2014') as result)
Go

What are these getdate and why two functions when get date is not used within query?
0
Comment
Question by:shmz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 250 total points
ID: 40457325
It doesn't make sense unless you have a function called ID.

I'm surprised if that runs.

You are correct - getdate() is not used within the second query, so it's redundant.
0
 
LVL 49

Accepted Solution

by:
Vitor Montalvão earned 250 total points
ID: 40457329
GETDATE() is used to pass the current date & time to the 2nd function since it has a datetime parameter (@asifdate).
But you're right, the parameter isn't used at all. Maybe it should since year='2014' is hardcoded and I think the idea should be year = year(@asifdate).
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40457336
Did you inherit these functions, and what are you trying to do here?
'What the hell is this?' is not the most actionable question.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql query help 15 52
sql 2016 data tools breakdown.. 1 26
How come this XML node is not read? 3 29
Finding Where Clause Value in SQL Views and SP 21 39
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question