Solved

What does @ symbol usually represents within the SQL coding?

Posted on 2008-06-13
4
239 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

17 Experts available now in Live!

Get 1:1 Help Now