﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Specify schema on table name / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 19:40:44 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Specify schema on table name</title><link>http://www.sqlservercentral.com/Forums/Topic1366932-391-1.aspx</link><description>(If SQL2008 is the same as SQL2005 in this regard, and I expect it is,...)Don't forget that even if my default schema is DBO-- if I execute the following 2 queries, they will NOT use the same cached execution plan....They may come up with identical EPs, but they will both be generated.[code="sql"]SELECT (some columns) FROM SomeTable WHERE (some condition)SELECT (some columns) FROM [b]DBO[/b].SomeTable WHERE (some condition)[/code]... and the following query won't reuse the EP from the first either...[code="sql"]SELECT (some columns) FROM                 SomeTable WHERE (some condition)[/code]</description><pubDate>Wed, 03 Oct 2012 14:10:03 GMT</pubDate><dc:creator>mstjean</dc:creator></item><item><title>RE: Specify schema on table name</title><link>http://www.sqlservercentral.com/Forums/Topic1366932-391-1.aspx</link><description>You will not get different query execution plan per user if you don't specify schema.Unless your system is designed in a such way (it's very rare case actually) that one group of users have a dedicated default schema and all relevant objects are duplicated in every such schema, it is always good idea to specify schema name.1. It explicitly suggest which schema the object belongs to2. Because of #1 you will get some performance benefits as compiler doesn't need to check which schema the object is from.</description><pubDate>Tue, 02 Oct 2012 04:59:36 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>RE: Specify schema on table name</title><link>http://www.sqlservercentral.com/Forums/Topic1366932-391-1.aspx</link><description>The dbo prefixing thing seemed to be a problem after changeover from SQL 2000 to SQL 2005, though what it was, I've forgotten.I've always thought it is generally good practise to prefix tables with the schema, and can remember companies that insisted all stored procedures were gone through to make sure all tables were prefixed with 'dbo.' But if you haven't upgraded from SQL2000 - then on 2005 or 2008, if the users in question have a different default schemas, then yes, Id' guess they would generate different plans, however usually the default schema is dbo - so if all users have the default schema it would not matter.Not sure I want to do this myself, but if you create two users in your northwind DB, make sure they have the same default schema, then execute the same statement without the dbo. a few times for each user, looking at the results of this query, to see what plans get cached.[code="sql"]SELECT TOP 10	plan_handle, sql_handle,       ObjectName          = OBJECT_SCHEMA_NAME(qt.objectid,dbid) + '.' + OBJECT_NAME(qt.objectid, qt.dbid)      ,TextData           = qt.text      ,DateCached         = qs.creation_time      ,LastExecutionTime  = qs.last_execution_time   FROM sys.dm_exec_query_stats AS qs   CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt   WHERE qt.text like '%Customers%'  -- or something in your query  ORDER BY plan_handle;[/code]I would guess you would see the plan reused.  Then create another user with a different schema, and see if when that user executes the query you get a new plan created.  I think you would see a different plan.  But I'll leave this up to someone else to test out and confirm/refute.</description><pubDate>Tue, 02 Oct 2012 04:54:04 GMT</pubDate><dc:creator>t.brown 89142</dc:creator></item><item><title>Specify schema on table name</title><link>http://www.sqlservercentral.com/Forums/Topic1366932-391-1.aspx</link><description>Hi,I can across this link on the net [url]http://www.sommarskog.se/dyn-search-2005.html[/url].Somewhere there's this:[quote]On lines 25-28 there is something very important:FROM   dbo.Orders oJOIN   dbo.[Order Details] od ON o.OrderID = od.OrderIDJOIN   dbo.Customers c ON o.CustomerID = c.CustomerIDJOIN   dbo.Products p ON p.ProductID = od.ProductIDAs you can see, I refer to all tables in two-part notation. That is, I also specify the schema (which in SQL 7/2000 parlance normally is referred to as owner.) If I would leave out the schema, each user would get his own his own private version of the query plan, so if there are ten users searching for orders there will be ten instances of the plan in cache. (As discussed in Curse and Blessings... it may work without specifying the schema on SQL 2005, but you should not rely on that.)[/quote]Since this article is written over SQL 2005 my question is: is this still true on SQL 2008?For each users that executes a SP, if the tables' names are not fully qualified, there's a execution plan for each user?This can be not so bad if each user has a different work mode and makes queries that have nothing to do with other users, I guess...Thanks,Pedro</description><pubDate>Tue, 02 Oct 2012 04:05:00 GMT</pubDate><dc:creator>PiMané</dc:creator></item></channel></rss>