SQL SERVER – Explanation and Example Four Part Name

What is four part name?

Explanation : ServerName.DatabaseName.DatabaseOwner.TableName

Example : localhost.AdventureWorks.Person.Contact

Reference : Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – Repeate String N Times Using String Function REPLICATE
Next Post
SQL SERVER – 2005 List All Tables of Database

Related Posts

No results found.

16 Comments. Leave new

  • In the example for a 4-part name, does the server name refer to the name of the computer or does it refer to the name of the SQL Server instance? These will not necessarily be the same names.

    Reply
  • Aren’t all indexes created as separate structures from a table? Although the index is created against a particular
    table, doesn’t the index itself exist in the database as a separate, self-contained structure?

    Which index type — clustered or nonclustered — logically
    sorts the database of a table?

    Reply
  • brother i will need to enter the data to the table of db1 from db2 and db1 is on remote server
    please send me the syntax if possible

    Reply
  • Hello Kasif,

    1. Copy data using Import/Export wizard or SSIS package.
    2. Insert data using OPENQUERY function
    3. Insert data using OPENROWSOURCE function
    4. Insert using 4 part naming. you would need to create a LinkedServer for this.
    5. Create script of data at source server and run on target database. As this would need more workaround so not recommonded.

    Regards,
    Pinal Dave

    Reply
  • Hi,
    I am very much impressed with your sql blogs and posting.Pinal I have newly stepped into SSIS package could you please help me around in this ….

    How to run a stored procedure in ssis package .And i have to pass the parameter’s from excel sheet .Like this

    =”exec st_example ‘” &F2 &”‘, ” & E2 & “, ‘” & H2 & “‘”

    and in the excel sheet , i need to pass the parameter by row by row .it would contains about 800 row ‘s .i am running this stored prod manually daily.

    And i have to schedule this job and send an alert mail.

    Reply
  • Sir i am new about to linked server.i am using this in my local server

    sp_addlinkedserver
    @server=’ip address of my remote server’,
    @srvproduct=”,
    @provider=’SQLNCLI’,
    @datasrc=’databasename’

    and then i make this query:

    SELECT *

    FROM OPENQUERY(‘ipadress’,databasename.uid.’select * from tbl_Products ‘)

    it not work. plz sir help me.
    Thanks
    Randeep Chauhan

    Reply
  • Can u explain about memory leak in sql server?

    Reply
    • yogigollapudi – In general SQL Server doesn’t leak memory. It’s by design of SQL that once it has grabbed memory, it would keep it to itself unless asked by operating system.
      This behavior is generally perceived as memory leak which is not true.

      Reply
      • Thank you for clarification.

      • Your welcome yogigollapudi!

      • yogigollapudi
        July 1, 2015 1:15 am

        Hi
        i am getting messages in errorlog as Process ID 400 was killed by hostname , host process ID 0.

        there is no hostname , and process ID 0, when i checked for process id in task manager , 0 is for system idle process.

        Could you please suggest me on this, what i have to check.

  • yogigollapudi – hostname and host process ID is empty for system processes. is there any other error which happened before that in ERRORLOG?

    Reply
    • does it happen at specific time? have you tried capturing a profiler?

      Reply
      • yogigollapudi
        July 15, 2015 8:12 pm

        yes i tried to capture with profiler but i have not found any clues, this is happening between 2 am to 11 am and getting almost 15-20 these error messages.

  • Mikkel Tronsrud
    March 2, 2017 5:43 pm

    Hi Dave,
    You write in this blobpost that the four part name consists of: ServerName.DatabaseName.DatabaseOwner.TableName.

    But isn’t actually
    ServerName,DatabaseName.SchemaName.TableName?

    In a lot of situations the DatabaseOwner and default schema will have the same name: e.g. [dbo]. But if a table belongs to a different schema, then at least I don’t get a connection by stating the DatabaseOwner.

    Regards,
    Mikkel

    Reply

Leave a Reply