What is the proper syntax in SQL Server for addressing tables?

前端 未结 7 447
-上瘾入骨i
-上瘾入骨i 2021-01-18 10:05

This seems like a fairly obvious question, but I haven\'t been able to think of the proper term for what I am trying to ask, so coming up with reference material for this ha

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-18 10:27

    SQL Server has four part names:

    • Most often you reference an object by name

      SELECT * FROM MyTable
      
    • Then you can specify the owner or schema of the object:

      SELECT * FROM dbo.MyTable
      
    • Then you can reference the database that the object lives in:

      SELECT * FROM master.dbo.MyTble
      
    • Finally you can reference the table on a different server

      SELECT * FROM test1.master.dbo.MyTable
      

    It's explained better than I can on MSDN

提交回复
热议问题