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
Printable View
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
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:
void GetPetName(int carID, out string petName) { petName = inventory.Single(i => i.CarID = carID).PetName; }
Thread moved to Database Development
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
hiQuote:
what is the meaning of this (@),plz explain
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