Structure of T-SQL tables - sql-server

I am switching from MySQL to SQL Server for a new job and I have encountered something I don't quite understand as I haven't encountered something like this before.
I am using the WideWorldImporters Microsoft Sample DB for reference.
Looking at the table structures I can see that it is SCHEMA_NAME.X.TABLE_NAME
Example
[WideWorldImporters].[Application].[Cities]
In MySQL this would just be schema.tablename
Example
[WideWorldImporters].[Cities]
What is this middle part (the [Application] part in the example) exactly? I can't seem to find anything about it but that's likely because I don't know what it is to look for.
It's obviously important as a select query won't work if it's removed. Can anyone explain or even name this so I can research it?

Microsoft uses a three-part naming pattern of Database_Name.Schema_Name.Table_Name that differs from the MySQL convention. In general terms, a MySQL "schema" is roughly equivalent to a SQL Server "database."
In practice, one should avoid explicitly referencing the database name unless specifically needed.
Microsoft documentation: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/transact-sql-syntax-conventions-transact-sql?view=sql-server-ver15#multipart-names

I would like to add some extra details on paneerakbari Accepted Answer
First: About SQL Server according to Microsoft Doc Transact-SQL has different formats to define Object name (Table name), Here are supported formats
Object reference format
Description
server.database.schema.object
Four-part name
server.database..object
Schema name is omitted.
server..schema.object
Database name is omitted
server...object
Database and schema name are omitted.
database.schema.object
Server name is omitted.
database..object
Server and schema name are omitted.
schema.object
Server and database name are omitted.
object
Server, database, and schema name are omitted.
For case you can use Two Formats, database.schema.object OR database..object Examples:
[WideWorldImporters].[Application].[Cities]
OR
[WideWorldImporters]..[Cities]
Second: About MySQL, the Schema name is Synonymous with the Database name So There is two SQL formats database.object OR object, Here are useful links describe Whats differents between Schema and Database in MySQL Stackoverflow Question And TutorialsPoint Question

Related

Is it possible to create table/views under a package in the schema?

In MS SQL Server 2012/oracle, I need to create something like a.b.c
where c is the table/view name, b is the package name and a is the
schema name.
I wanted to create a table/view in two levels. I couldn't find any
proper document regarding this. Any suggestion to find the good document
will be helpful.
MS SQL Server and Oracle are very different. They're both relational DBs, but different vendors and don't function quite the same. There are similarities though.
At any rate, you don't create tables under a package. A table is an object much like a package is an object. A package is designed to hold a collection of procedures/functions within Oracle. SQL Server doesn't even implement packages.
So, as an Oracle example, the best you're going to get is Database > account (or schema..) > table.

MSAccess linked tables SQL Server "is not a valid name" error

I have a third-party database that i want to link to but many table names are illegal - so i'm looking for a workaround, possibly including just keeping a duplicate database with acceptable (legal) naming structure,
that anybody might have tried.
many thanks
Within a SQL database you can CREATE SYNONYM to alias an object/table name to something usable within Access. Create synonms for all of the tables and then use those as your linked table names.

SSMS how to find entity in database

I have been told an entity called table_loader in a database, database_1 in SSMS (version 2008 R2) exists and needs to be fixed. It is not obviously a stored proc. It's purpose is to convert an excel spreadsheet to table data. Is there any easy way to search a database for an entity name in SSMS.
The find function appears to work only with text SQL files as opened in SSMS.
Since originally posting I have found out from a colleague that this entity is a DTS package; however, I believe searching a database for a name is still a useful thing to be able to do, especially if you don't know what "layer" the entity is in with respect to the database folder structure.
Thanks.
A great, free, tool is Red-Gate SQL Search. It lets you search for just about any object from SSMS in a very user-friendly manner. http://www.red-gate.com/products/sql-development/sql-search/. You just type in the object name and it will search across databases and object types and display what it finds. I like it because it also searches within sproc text and such which can be very helpful, depending on what you're looking for.
If you open up a query window in SSMS you can use the below SQL to do a wildcard search:
USE [dbname]
SELECT * FROM sysobjects WHERE name like '%table_loader%'
This thread has got some good queries and lists the xtype meanings (sproc, table, key etc):
How do I get list of all tables in a database using TSQL?

How to get the definition for a view only accessable via synonym in an Oracle database?

Is there any way to get the type or general table/view definition from an Oracle database synonym? Are special rights neccessary to get it or is it even impossible and I have to check the real source database?
I am especially interested in the column datatypes and length of the type (where it matters).
Thanks a lot in davance.

SQL Server 2012 - Synonyms

SQL Server 2005/8 allows you to associate a synonym with a remote table (i.e. a table on a different instance - the reference is via a 4-part name, which includes the link server name). Does anyone know whether SQL Server 2012 allows a synonym to be directly associated to the Link Server name (rather than a table which exists on the target)
Looking at the Books Online for SQL Server Denali, there appears to be no change in syntax or usage for SYNONYM's. Probably a safe bet to assume there will be no difference.
Why don't you just duplicate the linked server with your desired new name?
That's not a synonym, but the same server will be available with two names, so in practice they are pretty much the same.

Resources