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
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; }
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB | C#
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces
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
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
hiwhat 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
Last edited by firoz.raj; Jul 24th, 2012 at 04:01 PM.