Solved

What does @ symbol usually represents within the SQL coding?

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
length of the password hash sha1:64000 to set sql field property. 13 89
table joins in qry 17 88
Union & Crosstab qrys 101! 6 58
SQL Select Query help 1 38
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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