|
-
Jul 23rd, 2012, 01:31 AM
#1
Thread Starter
Junior Member
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
-
Jul 23rd, 2012, 02:13 AM
#2
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:
void GetPetName(int carID, out string petName) { petName = inventory.Single(i => i.CarID = carID).PetName; }
-
Jul 23rd, 2012, 05:07 AM
#3
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
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jul 24th, 2012, 09:39 AM
#4
Fanatic Member
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
-
Jul 24th, 2012, 03:54 PM
#5
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|