Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7539279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:20:24+00:00 2026-05-30T07:20:24+00:00

if I have a function ALTER FUNCTION [dbo].[GetCycleDate] ( ) RETURNS DATE AS BEGIN

  • 0

if I have a function

ALTER FUNCTION [dbo].[GetCycleDate]
(
)
RETURNS DATE
AS
    BEGIN
        DECLARE @CYC_DT DATE

        SELECT
            @CYC_DT = CYC_DT
        FROM
            CYC_DT
        WHERE
            CURR_CYC_IND = 'C'

        RETURN @CYC_DT

END

For a very large table, will these two SQLs perform almost the same?

SELECT
    *
FROM
    [dbo].Table S
    INNER JOIN dbo.CYC_DT D ON  
        S.GL_DT = D.CYC_DT AND
        D.CURR_CYC_IND = 'C'


SELECT
    *
FROM
    [dbo].Table S
WHERE

    S.GL_DT = dbo.GetCycleDate() 

I know avoiding the function is safer, but for testing purposes, I want to be able to rig the function to return a hard coded result without impacting the testing done by other people who are relying on a different date to be set in the Cycle date table. I want to be able to switch to a different date on the without impacting anyone else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:20:26+00:00Added an answer on May 30, 2026 at 7:20 am

    Generally a bad idea to do this, as the optimizer is more limited in what it can do for you when scalar UDFs are involved.:

    http://blogs.msdn.com/b/dfurman/archive/2009/12/02/query-performance-scalar-udfs-and-predicate-pushdown.aspx

    http://www.sql-server-performance.com/2005/sql-server-udfs/

    Since your scalar UDF isn’t parameterized, and your sample query is simple, you might get away with it, but you’d have to test to be sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following recursive function: ALTER FUNCTION [dbo].[ListAncestors] ( @Id int ) RETURNS
I have a Scalar-valued function in my DB: ALTER FUNCTION [dbo].[fx_fooFunct] (@MyParam varchar(max)) RETURNS
I have the following tsql function: ALTER FUNCTION [dbo].[fn_MyFunc] ( @AccountId varchar(50) ) returns
I have the following function ALTER FUNCTION [dbo].[ActualWeightDIMS] ( -- Add the parameters for
I have a Function like this; ALTER FUNCTION [dbo].[fngcodeme] ( @HESAP INT, @DOV INT,
I have a function that works like this: select score from comparestrings(@String1,@string2) I need
I have a SQL Function like this; ALTER FUNCTION [dbo].[fngcodeme] ( @HESAP INT, @DOV
I have a simple function that returns an NSString after decoding it. I use
I have a jQuery post function that returns a response on success after the
i have function public Menu Details(int? id) { return _dataContext.Menu.Include(ChildMenu).FirstOrDefault(m => m.MenuId == id);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.