February 9, 2010 at 9:37 pm
Comments posted to this topic are about the item Curiouse View to create for SQLServer 2005
February 9, 2010 at 11:09 pm
An interesting question, but a very roundabout way of asking "Does SQL Server 2005 support OPTION (...) hints within Views?" 😉
S.
February 9, 2010 at 11:21 pm
This was removed by the editor as SPAM
February 10, 2010 at 12:47 am
.. it doesn't .. but you can create a sp instead when you want to use cte.
Normal OPTION () hints can only be used within select's as i know:-P
February 10, 2010 at 2:24 am
matt32 (2/10/2010)
but you can create a sp instead when you want to use cte
... or you can create a view without OPTION clause and add OPTION to the SELECT statement 🙂
SELECT *
FROM month_since_200701
OPTION(MAXRECURSION 0)
February 10, 2010 at 6:53 am
I thought it was a good question. It caused me to think and read a couple of times to make sure of what I was reading. It also caused me to remember something that I hadn't though of in a long time thus refreshing my memory.
Steve Jimmo
Sr DBA
“If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
February 10, 2010 at 7:02 am
sjimmo (2/10/2010)
"it doesn't .. but you can create a sp instead when you want to use cte"Matt32 - The question was about a view.
Why do so many complain about a question that is not there? If the question is for a view, why do we not address it from that aspect?
I felt it is a good question. But Matt is not complaining here. He is giving an alternative to use CTE OPTION in proc instead of view.
SQL DBA.
February 10, 2010 at 8:04 am
I got it right, but for the wrong reason. Is it my imagination or is the UNION ALL in the wrong spot? Shouldn't it go between the SELECTs?
Chad
February 10, 2010 at 8:25 am
Chad Crawford (2/10/2010)
I got it right, but for the wrong reason. Is it my imagination or is the UNION ALL in the wrong spot? Shouldn't it go between the SELECTs?Chad
It's in the right place. The UNION ALL is already between the two SELECTs within the CTE. That's what enables the recursive nature of the CTE -- having that anchor point defined (the 2007-01-01)
February 10, 2010 at 9:16 am
The union all is properly placed. The formatting of the question is a little awkward - so it looks wrong at first glance.
Thanks (Matt) for the question.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 10, 2010 at 10:18 am
Yes, it was me reading more into it - probably because it happens so often.
Sorry Matt
Steve Jimmo
Sr DBA
“If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
February 10, 2010 at 10:51 am
Hi Steve,
no problem , i haven't had the time to write a proper article on how to create a view with Option()
at the end of the statement .. but here is the short way.
1. Create a SP
2. Use Eli's SP to create a View
http://www.sqlservercentral.com/articles/T-SQL/68233/
Sometimes it is useful to use OPTION() to kick the optimizer into the right direction 😉
This small calendar i used for reporting sale gaps ... nothing is more difficult than reporting data that not exists :w00t:
Regards Matthias
March 30, 2010 at 8:53 am
Using OPENROWSET that way is just wrong!!! 😀
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 30, 2010 at 9:35 am
Paul White NZ (3/30/2010)
Using OPENROWSET that way is just wrong!!! 😀
Uh..... wrong thread, maybe? What OPENROWSET?
March 30, 2010 at 10:00 am
the OPENROWSET within Eli Leibas SP to create a view from the output of another SP:-)
http://www.sqlservercentral.com/articles/T-SQL/68233/
this is cool and i use it often
Viewing 15 posts - 1 through 15 (of 17 total)
You must be logged in to reply to this topic. Login to reply