Solved

What does @ symbol usually represents within the SQL coding?

Posted on 2008-06-13
4
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

728 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