Sunday, January 14, 2018

How To Create Sql Aliases In Mssql

Hello Friend Today In This Blog I Will Show You How To Create Sql Aliases In Mssql. SQL Aliases are defined for columns and tables. Basically aliases is created to make the column selected more readable.SQL aliases are used to give a table, or a column in a table, a temporary name.Aliases are often used to make column names more readable.An alias only exists for the duration of the query.Alias is used to give an alias name to a table or a column. This is quite useful in case of large or complex queries. Alias is mainly used for giving a short alias name for a column or a table with complex names.A SQL alias is an alternative name given to a SQL server that is more familiar to the user. It is like a nickname for a person, except it is for a server. Sometimes server names can be complex and hard to remember, this is where an alias would come in handy. Instead of having “Prod _SRV_SP_SQL_1” as the server name, you can use “SQL1” or any variation of that for simplification. Creating an alias for a SQL server is recommended when building a new production SharePoint server farm for many reasons.

While you are building a new farm, it is important to consider what actions need to take place if your database server fails. Having a SQL alias will allow you to switch database servers and continue running all of your applications as normal. Without a SQL alias you would have to go into each application that touches SQL and manually reconfigure the connection. With SharePoint if you have one database server and no alias you would have to rebuild your existing farm and point to your existing databases (Restored from backups). 

Having a SQL alias will also provide you with a performance boost. When SharePoint connects to SQL it goes through the available protocols to determine how to send and receive information. With an alias you can specify a protocol to speed up this process. When creating an alias you should select TCP/IP (Transmission Control Protocol) as the preferred protocol. It is reliable and provides error checking for information that is sent/received. Make sure you document your SQL alias for future reference.

Alias Column Syntax

SELECT column_name AS alias_name

FROM table_name;


Alias Table Syntax

SELECT column_name(s)

FROM table_name AS alias_name;

Here Is An Example Related To Topic


Step 1 :Create database


Create database Users


Step 2:Create table

Here In This step We Will Create table.

Here In This Step We Required Four Column With Name uids ,uname ,ulocation and uaddresses using Parameter bigint,varchar.


create table usertype
(
uids bigint,
uname varchar(50),
ulocation varchar(50),
uaddresses varchar(200)
);




Step 3:view data using store procedure

Here In This Step We Will Create View Procedure Using Select Trigger Functionality. 

Here Aliases Are Also Given.

create Procedure wb_view_Usertype
as
begin
select 
ISNULL(uids,'-') as UIDS,
ISNULL(uname,'-')as NAME,
ISNULL(ulocation,'-')as LOCATION,
ISNULL(uaddresses,'-')as ADDRESSES
from usertype

end




Video Related To Topic Is Here Just Click On It......






No comments:

Post a Comment