sql server - SET DATEFIRST inside function -


i have database holds multiple modules. module i'm working on works different start date rest of modules. in module need, @ 1 point, calculations rely on first day of week inside function created calculations tried putting set datefirst which, found out, doesn't work. put out fire, i've put set datefirst outside of function call, i'm refactoring , better alternative. other discussions on topic either set outside function or change logic not depend on it. problem setting outside of function kind of defeats purpose of function , changing logic not simple whatever do, needs rely on specific day being first day of week (it's not 1 line needs rely on it). additionally, logic relatively complex (that's part of reason why it's function , not inline code in sp) rewriting in such way both error-prone , difficult read , change when needed i'm looking better alternative.

so there better alternative having different datefirst in user-defined function than:

  • calling set datefirst outside function
  • rewriting logic not rely on it?

i assume answer no, wanted see if has idea.

if replace udf stored procedure, not have limitation of not being able use set datefirst.

you can capture output of stored procedure inside either output parameters noted in comments above, or using structure:

insert @sometablevariableortemptable (col1, col2, ... coln) exec mystoredprocedure; 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -