January 3, 2017 at 12:29 pm
Michael L John (1/3/2017)
Just putting the finishing touches on a new reporting server.I run this old legacy ETL process that nobody knows about, and nobody remembers, when this error occurs:
Msg 4121, Level 16, State 1, Procedure ETL_sp_Source_Dimensions_AT, Line 1168 [Batch Start Line 0]
Cannot find either column "Master" or the user-defined function or aggregate "Master.dbo.fn_WorkDays", or the name is ambiguous.
Msg 4121, Level 16, State 1, Procedure ETL_sp_Update_Offline_Data, Line 57 [Batch Start Line 0]
Cannot find either column "Master" or the user-defined function or aggregate "Master.dbo.fn_WorkDays", or the name is ambiguous.
What? Why would they create this function in master? It's probably loops and cursors and lots of other bad stuff.
I open the function, and this appears in the comments:
Revisions:
Rev 00 - 12/12/2004 - Jeff Moden - Initial creation and test.
Rev 01 - 12/12/2004 - Jeff Moden - Load test, cleanup, document, release.
Rev 02 - 12/26/2004 - Jeff Moden - Return NULL if @StartDate is NULL or DEFAULT and
modify to be insensitive to DATEFIRST settings.
*
Well, no loops here!
I'm guessing that this is the function: http://www.sqlservercentral.com/articles/Advanced+Querying/calculatingworkdays/1660/
I'm also guessing that Jeff would suggest to stop using that function and change it into an iTVF.:-D
January 3, 2017 at 12:54 pm
ICYMI: SQL in the City Streamed playlist: https://www.youtube.com/playlist?list=PLhFdCK734P8DvVfg9O_csDlxp7jeyAsXV
January 3, 2017 at 1:36 pm
Luis Cazares (1/3/2017)
Michael L John (1/3/2017)
Just putting the finishing touches on a new reporting server.I run this old legacy ETL process that nobody knows about, and nobody remembers, when this error occurs:
Msg 4121, Level 16, State 1, Procedure ETL_sp_Source_Dimensions_AT, Line 1168 [Batch Start Line 0]
Cannot find either column "Master" or the user-defined function or aggregate "Master.dbo.fn_WorkDays", or the name is ambiguous.
Msg 4121, Level 16, State 1, Procedure ETL_sp_Update_Offline_Data, Line 57 [Batch Start Line 0]
Cannot find either column "Master" or the user-defined function or aggregate "Master.dbo.fn_WorkDays", or the name is ambiguous.
What? Why would they create this function in master? It's probably loops and cursors and lots of other bad stuff.
I open the function, and this appears in the comments:
Revisions:
Rev 00 - 12/12/2004 - Jeff Moden - Initial creation and test.
Rev 01 - 12/12/2004 - Jeff Moden - Load test, cleanup, document, release.
Rev 02 - 12/26/2004 - Jeff Moden - Return NULL if @StartDate is NULL or DEFAULT and
modify to be insensitive to DATEFIRST settings.
*
Well, no loops here!
I'm guessing that this is the function: http://www.sqlservercentral.com/articles/Advanced+Querying/calculatingworkdays/1660/
I'm also guessing that Jeff would suggest to stop using that function and change it into an iTVF.:-D
The next step is to take this database offline, and see if anyone notices. It's that old.
Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
January 3, 2017 at 7:27 pm
Luis Cazares (1/3/2017)
Michael L John (1/3/2017)
Just putting the finishing touches on a new reporting server.I run this old legacy ETL process that nobody knows about, and nobody remembers, when this error occurs:
Msg 4121, Level 16, State 1, Procedure ETL_sp_Source_Dimensions_AT, Line 1168 [Batch Start Line 0]
Cannot find either column "Master" or the user-defined function or aggregate "Master.dbo.fn_WorkDays", or the name is ambiguous.
Msg 4121, Level 16, State 1, Procedure ETL_sp_Update_Offline_Data, Line 57 [Batch Start Line 0]
Cannot find either column "Master" or the user-defined function or aggregate "Master.dbo.fn_WorkDays", or the name is ambiguous.
What? Why would they create this function in master? It's probably loops and cursors and lots of other bad stuff.
I open the function, and this appears in the comments:
Revisions:
Rev 00 - 12/12/2004 - Jeff Moden - Initial creation and test.
Rev 01 - 12/12/2004 - Jeff Moden - Load test, cleanup, document, release.
Rev 02 - 12/26/2004 - Jeff Moden - Return NULL if @StartDate is NULL or DEFAULT and
modify to be insensitive to DATEFIRST settings.
*
Well, no loops here!
I'm guessing that this is the function: http://www.sqlservercentral.com/articles/Advanced+Querying/calculatingworkdays/1660/
I'm also guessing that Jeff would suggest to stop using that function and change it into an iTVF.:-D
Heh... oh my. That was my very first article from 12 years ago. Love what you did with Rev 03. 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
January 3, 2017 at 9:39 pm
Sean Lange (1/3/2017)
The real downside is that overall it really seems like the number of questions has significantly decreased over the last 6-12 months. Hopefully this is just a trend and it will turn around in the near future.
Ditto.
-- Itzik Ben-Gan 2001
January 3, 2017 at 9:45 pm
Luis Cazares (12/27/2016)
Carrie Fisher is now one with the force.[/url] :crying:Can 2016 end already?
-- Itzik Ben-Gan 2001
January 4, 2017 at 5:44 am
Sean Lange (1/3/2017)
Many thanks to you, Ed and anyone else bearing this task.
You're most welcome. I've gotten a lot from using this site and I just want to help keep it the best in the world.
January 4, 2017 at 5:48 am
Alan.B (1/3/2017)
Sean Lange (1/3/2017)
The real downside is that overall it really seems like the number of questions has significantly decreased over the last 6-12 months. Hopefully this is just a trend and it will turn around in the near future.Ditto.
Yes it does. The questions seem fewer, but I haven't seen any statistics on it. The number of SS-style questions are up. I originally said I never wanted to skip responding to a post because of who it was from, but I admit I've implemented my own "black list" because I found that the frustration of trying to teach someone who doesn't want to learn was too much.
January 4, 2017 at 6:55 am
Repost from Twitter:
Research for a blog post: What are the common forms of 'catch-all' / 'multi-parameter query' you've seen?
I've seen:
(Col = @C1 or @C1 is NULL)
Col = COALESCE(@C1, Col) (and a similar form with ISNULL)
Col = CASE WHEN @C1 is NULL THEN Col ELSE @C1 END.
CASE WHEN @C1 is NULL THEN 1 WHEN Col = @C1 THEN 1 ELSE 0 END = 1
What else?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 4, 2017 at 7:22 am
GilaMonster (1/4/2017)
Repost from Twitter:Research for a blog post: What are the common forms of 'catch-all' / 'multi-parameter query' you've seen?
I've seen:
(Col = @C1 or @C1 is NULL)
Col = COALESCE(@C1, Col) (and a similar form with ISNULL)
Col = CASE WHEN @C1 is NULL THEN Col ELSE @C1 END.
CASE WHEN @C1 is NULL THEN 1 WHEN Col = @C1 THEN 1 ELSE 0 END = 1
What else?
Here are two numeric specific methods that you are missing, I tend to use the second one.
😎
ISNULL(((COL + @N) - @N),0) = ISNULL(@N,0)
COL BETWEEN ISNULL(@N,-2147483648) AND ISNULL(@N,2147483647)
Edit: missed this one
Method for a character predicate
[Name] LIKE ISNULL(@NAME,'%')
January 4, 2017 at 7:49 am
DBMS of the year, apparently - http://db-engines.com/en/blog_post/67
January 4, 2017 at 8:06 am
BrainDonor (1/4/2017)
DBMS of the year, apparently - http://db-engines.com/en/blog_post/67
At a 100,000 foot view, sounds more like a report on marketing success than anything else. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
January 4, 2017 at 8:14 am
Jeff Moden (1/4/2017)
BrainDonor (1/4/2017)
DBMS of the year, apparently - http://db-engines.com/en/blog_post/67At a 100,000 foot view, sounds more like a report on marketing success than anything else. 🙂
Close, but not quite.
Method of calculating the scores of the DB-Engines Ranking
The DB-Engines Ranking is a list of database management systems ranked by their current popularity.
January 4, 2017 at 8:20 am
Eirikur Eiriksson (1/4/2017)
GilaMonster (1/4/2017)
Repost from Twitter:Research for a blog post: What are the common forms of 'catch-all' / 'multi-parameter query' you've seen?
I've seen:
(Col = @C1 or @C1 is NULL)
Col = COALESCE(@C1, Col) (and a similar form with ISNULL)
Col = CASE WHEN @C1 is NULL THEN Col ELSE @C1 END.
CASE WHEN @C1 is NULL THEN 1 WHEN Col = @C1 THEN 1 ELSE 0 END = 1
What else?
Here are two numeric specific methods that you are missing, I tend to use the second one.
😎
ISNULL(((COL + @N) - @N),0) = ISNULL(@N,0)
COL BETWEEN ISNULL(@N,-2147483648) AND ISNULL(@N,2147483647)
Edit: missed this one
Method for a character predicate
[Name] LIKE ISNULL(@NAME,'%')
Note that both for the versions in your post as well as for the versions given by Eirikur, only some work correctly for nullable columns.
Additionally, the numeric methods mentioned by Eirikur depend on the data type.
They can easily be modified to work with date/time data as well, and then still depend on the data type.
I consider all of these to be bad ideas.
(I have seen the first three in your post, and I will not always rip it out. I do usually add a RECOMPILE query hint to such queries)
Another pattern that I have used is
IF @C1 IS NOT NULL
BEGIN;
SET @Qry += ' AND Col1 = @C1';
END;
(...)
EXEC sp_executesql @Qry, '@C1', @C1;
January 4, 2017 at 8:34 am
BrainDonor (1/4/2017)
DBMS of the year, apparently - http://db-engines.com/en/blog_post/67
I use this list a lot (and usually Microsoft hovers around #3 or #4, occasionally #2). It's a great tool for discussing why Accumulo (or pick the obscure NOSQL db du jour) may not be a great choice for your career. It's not that great a measure of which DBMS is better, just which one is getting used a lot.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 15 posts - 57,016 through 57,030 (of 66,712 total)
You must be logged in to reply to this topic. Login to reply