SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Popup population

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Popup population
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Popup population Reply with quote
After typing SELECT the popup is already filled by schemas, built-in functions, databases, variables, etc. and by objects from 'dbo' schema. Objects from other schemas can be accessed by selecting their schem with the right arrow and filtering further. This is very easy when the schema of the object is known but it makes looking for an object with unknown schema less than optimal. Is there a way (e.g. by altering DB Queries or something) to make the initial popup contain all the objects of the different schemas with their schema indicated as a separate column in the popup? Or at least (if it would make things slow), make it populate the list from the user's default schema instead of 'dbo'.

EDIT: I've just noticed that it does get populated from the user's default schema. Except when the login of the user has sysadmin role assigned to it. It seems that using such a login to connect to the database will always result in username being 'dbo' with the default schema 'dbo', hence the popup contains objects from 'dbo' as well. It looks like there is some kind of inconsistency in how SQL Server handles logins with sysadmin role :(
Fri Sep 14, 2012 4:41 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
The current schema is derived from "Context" query. Please note it uses ISNULL(SCHEMA_NAME(), ''dbo'')') to get the current schema name. You may want to tweak this query to do a better work for you.
Fri Sep 14, 2012 6:39 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
Thanks for the info. I modified Context to
Code:

   SELECT
   SERVERPROPERTY( 'ServerName' )
   ,SYSTEM_USER
   ,DB_NAME()
   ,COALESCE(
       (
           SELECT
              dp.default_schema_name
           FROM
              sys.database_principals AS dp
           WHERE   1 = 1
              AND   dp.principal_id = USER_ID( SYSTEM_USER )
        )
       ,SCHEMA_NAME()
       ,'dbo'
    )

so that it retrieves the default schema instead of 'dbo' for logins with sysadmin role. It seemed to work until I got some objects created in dbo schema, after which they were added to the popup even if the default schema was other than 'dbo' and selecting them from the popup prefixed them with the default schema instead of 'dbo'. I guess I'll just restore the original Context. It's not that important at all.
Sun Sep 16, 2012 2:29 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.