How to find out the Objects Defacults Schema Details

  • HI All,

    I would like to change the default schema details of all the logins created

    Could yoy please specify how do i find out the schema details

    and also i would like to change all the objects default schema to DBO

    Regards'

    Smm

  • shine.mm (4/1/2008)


    HI All,

    I would like to change the default schema details of all the logins created

    Could yoy please specify how do i find out the schema details

    and also i would like to change all the objects default schema to DBO

    Regards'

    Smm

    What schema details do you want to know exactly?

    To change the default schema:

    ALTER USER Mary51 WITH DEFAULT_SCHEMA = dbo

    To change objects to the default schema use:

    ALTER SCHEMA dbo TRANSFER fully_qualified_object_name

    Hope that helps.

  • Hi,

    What i would need is i would like to know each databases,Which are the Objects(Tables,Stored Procedures Etc.)not belong to the schema DBO.

    Fist i need to know which are the objects not belong to DBO

    Then i would like to change the schema of this objects to DBO

    Please help me

    Smm

  • shine.mm (4/2/2008)


    Hi,

    What i would need is i would like to know each databases,Which are the Objects(Tables,Stored Procedures Etc.)not belong to the schema DBO.

    Fist i need to know which are the objects not belong to DBO

    Then i would like to change the schema of this objects to DBO

    Please help me

    Smm

    This query will give you objects in a single database that do not belong to dbo. I've also constructed the command you'd need to run to transfer the object to a different schema.

    select schema_name(schema_id), name, command = 'ALTER SCHEMA dbo TRANSFER [' + schema_name(schema_id) + '].[' + name + ']'

    from sys.objects

    where schema_name(schema_id) <> 'dbo'

    and type in('U','P','V', 'FN','TF','IF')

  • hi,

    Is there any method to find out

    Database users which do not have DBO as their default schema.

    Any query

    Smm

  • You can use the following script for a specific database -

    SELECT *

    FROM sys.database_principals

    WHERE [type] IN ('U','S')

    AND ISNULL(default_schema_name,'')<>'dbo'

    Chandrachurh Ghosh
    DBA – MS SQL Server
    Ericsson India Global Services Limited
    Quality is not an act, it is a habit.

  • Thanks alot,Also I would need couple of details ,could you help me

    ---

    This is what I needed,

    1)Objects which do not belong to DBO

    This is the query we are using to find out

    select schema_name(schema_id)as ObjectName, name,type,type_desc from sys.objects

    where schema_name(schema_id) <> 'dbo'

    and type in('U','P','V', 'FN','TF','IF','PK','UQ')

    go

    2)Database users which do not have DBO as their default schema

    SELECT *

    FROM sys.database_principals

    WHERE [type] IN ('U','S')

    AND ISNULL(default_schema_name,'')<>'dbo'

    We would like to create a report out of it and let a procedure run in every instance on a daily basis. The procedures should write the information into seperate tables in theOne of DB(Like ABC)database

    I need to have the Sp in one Database and it needs to check all the Database and fetch the details into separate tables as per the database name

    Could you please help me

  • HI chandru,

    I posted one topic ,could you please help me

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply