Solved

What does @ symbol usually represents within the SQL coding?

Posted on 2008-06-13
4
227 Views
Last Modified: 2008-06-30
I am reviewing SQL coding and I noticed that @ symbol repeats so many times. I am also posting the sample code for you to review.
My question is what is usually represented by @ symbol within SQL.
Thank You, A.

create proc mic_is_in_role
 @RoleName varchar(24) = null,
 @loginId varchar(16) = null
as
--DESCRIPTION: returns 0 if user login id is in role, otherwise returns a value less than 0
set nocount on
 
if (@RoleName is null OR @loginId is null) begin
  return 10201
end  
 
if exists (select *  
           from ncx_roles
           where RoleName = @RoleName
           and LoginId = @loginId) begin
 return 0           -- yes, loginid is in role
 
end else begin
0
Comment
Question by:gotiva
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 21778670
Hello gotiva,

The @ symbol is denoting a locally declared variable. In this case as it is a stored procedure, the two variables @RoleName and @LoginID are declared and receive the values passed into the stored procedure. They are then used locally (to the statement batch - in this case the stored procedure) to provide a match for a record in the table ncx_roles against similarly named columns.

Regards,

TimCottee
0
 
LVL 6

Expert Comment

by:powercram
ID: 21778693
The @ (at symbol) is equivalent to the START command and is used to run SQL*Plus command scripts.

A single @ symbol runs a script in the current directory (or one specified with a full or relative path, or one that is found in you SQLPATH.

@@ will start a sqlplus script that is in the same directory as the script that called it (relative to the directory of the current script). This is normally used for nested command files.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 21778709
powercram,

I don't think that applies to MS SQL Server!

TimCottee
0
 

Author Comment

by:gotiva
ID: 21778820
Thank You.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now