Results 1 to 5 of 5

Thread: what is the meaning of this (@),plz explain

  1. #1
    Junior Member
    Join Date
    Jul 12
    Posts
    22

    what is the meaning of this (@),plz explain

    What is meaning of this (@) , i sawed this in stored procedure .

    for example
    "
    CREATE PROCEDURE getpetname
    @carid int,
    @petname char (10) output
    AS
    SELECT @petname = petname from inventory where carid = @carid
    "
    why we use @ in this.plz explain

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    81,236

    Re: what is the meaning of this (@),plz explain

    This question has nothing to do with C# so it doesn't belong in the C# forum. Only question specifically related to C# belong in this forum. That is SQL code so the question belongs in the Database Development forum. I will ask the mods to move this thread.

    The @ prefix denotes a parameter or variable in T-SQL code, which behave in much the same way as parameters and variables in any programming language, e.g. C#. A C# method that did something similar to that procedure might look like this:
    csharp Code:
    1. void GetPetName(int carID, out string petName)
    2. {
    3.     petName = inventory.Single(i => i.CarID = carID).PetName;
    4. }

  3. #3
    Super Moderator koolsid's Avatar
    Join Date
    Feb 05
    Location
    Mumbai, India
    Posts
    11,449

    Re: what is the meaning of this (@),plz explain

    Thread moved to Database Development
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

  4. #4
    Fanatic Member
    Join Date
    Jun 04
    Location
    All useless places
    Posts
    916

    Re: what is the meaning of this (@),plz explain

    Further to what @jmcilhinney said

    Take a look at http://msdn.microsoft.com/en-us/libr...arameters.aspx on how to pass parameters when calling a parameterized query. They are more secure and save you from SQL Injections.

    An example for SP's: http://support.microsoft.com/kb/310130

  5. #5
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,434

    Talking Re: what is the meaning of this (@),plz explain

    what is the meaning of this (@),plz explain
    hi
    normally we declare variable with prefix @ .means @x int means x is a integer type variable .without @ sign. sql compiler will understood its table or fields name .hope it is clear now .
    Code:
    @variableName datatype
    
    
     @x int                  --------sql server
     dim x as integer        --------in vb6 & in vb.net
    Last edited by firoz.raj; Jul 24th, 2012 at 04:01 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •