Synonyms in SQL Server 2005

Source: Internet
Author: User
Tags scalar

from: http://blog.csdn.net/itblog/article/details/752881

============= Creating synonyms

You can create synonyms for the following object types:

Assembly (CLR) stored procedures

Assembly (CLR) table-valued functions

Assembly (CLR) scalar functions

Program Clustering (CLR) aggregation functions

Replication filtering process

Extended stored Procedures

SQL scalar functions

SQL table-valued functions

SQL Inline table-valued functions

SQL Stored Procedures

View

Table 1 (User defined)

1 including local and global temporary tables

Using the four-part name of a function base object is not supported.

Synonyms can be created, deleted, and referenced in dynamic SQL.

After you do not reference or do not need synonyms, you can delete synonyms.

--a: Creating synonyms for local objects
==================================================================
CREATE synonym Mybom
For TEST. Dbo. BOM;
GO
SELECT *
From Mybom
WHERE ID < 5;
GO

--b: Creating Synonyms for remote objects
==================================================================
--Create a linked server
exec sp_addlinkedserver ' srv_lnk ', ' ', ' SQLOLEDB ', ' Remote server name or IP address '
exec sp_addlinkedsrvlogin ' Srv_lnk ', ' false ', NULL, ' username ', ' password '
GO
Use DatabaseName
CREATE synonym with the word for srv_lnk. remote database. dbo. remote table;
GO
SELECT * from the same word

--Remove linked server when no longer in use
exec sp_dropserver ' srv_lnk ', ' droplogins '

======== Deleting synonyms ===================================================
References to synonyms are not schema-bound, so synonyms can be removed at any time. A reference to a deleted synonym can only be found at run time. Synonyms can be created, deleted, and referenced in dynamic SQL.

DROP synonym synonym Name

---------------------->>>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.