Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
Synonyms in SQL Server 2005
Osolage
follow
1
10-25-2007 1:12 PM
869 views
tags:
sql server
,
database
,
tips
Osolage
says:
I think this is going help me out quite a bit in the future.
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Related Clips
Dynamic SQL & Table variables
Cheat Sheet Roundup - Over 30 Cheatsheets ...
Sql Server and .NET Min and Max Date Ranges
Easy Way to Request Hotfix from Microsoft
SQL语句的执行:Statement、PrepareStatement、Callab...
Free Web Bulding-This I Like
A Startup A Week
More clips from
Osolage
SQL Server 2005 Developer Edition
Wesabe protects user data
Quote: The Important Story About OpenSocial
Today's Top Clips
What pets do when we're at work.....
Thousands of New Species Discovered on Tiny Island
Made From Snow
Dog saves dog on freeway
Journey through the birth, life and death of stars..Amazing pictures
Is this the world's oldest living creature?
How Comics Can Save Us From Scientific Ignorance
The oscillations of Rudolfo Llinás : Seeing a Brain Out of Rhythm
Can our "private" Emotions follow general rules ?
"How The Nazis Stole Christmas"
visit the
Top Clips page
View the Top Clips from
October 25, 2007
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/c86553f1-5606-4076-8c75-a138c577b2a6/D65D17DD-5A2C-42FD-8D38-06A6135F915D/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://www.developer.com/db/article.php/3613301" href="http://www.developer.com/db/article.php/3613301" style="font-size: 11px;">www.developer.com</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.developer.com/db/article.php/3613301"><FONT size="-1" face="Verdana, Arial, Helvetica">SQL Server 2005 introduces the concept of a <I>synonym</I>: a single-part name that can replace a two-, three-, or four-part name in many SQL statements. Using synonyms lets you cut down on typing (always a welcome advance for developers!) and can also provide an abstraction layer to protect you against changes in underlying objects. To understand how this works, let's start with the syntax for creating synonyms. Not surprisingly, this is the <CODE>CREATE SYNONYM</CODE> statement:</FONT></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.developer.com/db/article.php/3613301"><FONT size="-1" face="Verdana, Arial, Helvetica">For example, in the AdventureWorks sample database you can create a synonym this way:</FONT></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.developer.com/db/article.php/3613301"><PRE><CODE> <FONT size="-1" face="Verdana, Arial, Helvetica">CREATE SYNONYM ProdCat FOR AdventureWorks.Production.ProductCategory </FONT></CODE></PRE></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.developer.com/db/article.php/3613301"><FONT size="-1" face="Verdana, Arial, Helvetica">Having done this, you can now proceed to use the synonym in SQL statements. For example:</FONT></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.developer.com/db/article.php/3613301"><PRE><CODE> <FONT size="-1" face="Verdana, Arial, Helvetica">SELECT * FROM ProdCat </FONT></CODE></PRE></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/D65D17DD-5A2C-42FD-8D38-06A6135F915D/blog/" title="blog or email this clip"><img src="http://content6.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK