what the true nature of @ in Transct-SQL

Posted by Richard77 on Stack Overflow See other posts from Stack Overflow or by Richard77
Published on 2010-04-20T20:53:19Z Indexed on 2010/04/20 21:03 UTC
Read the original article Hit count: 316

Filed under:
|

Hello,

I reading some old ScottGu's blogs on Linq2SQL. Now I'm doing the SPROC part. I'd like to know what's the exact meaning of @variable.

See this from ScottGu's Blog

ALTER PROCEDURE dbo.GetCustomersDetails
(
  @customerID nchar(5),
  @companyName nvarchar(40) output
)
AS
SELECT @companyName = CompanyName FROM Customers
WHERE CustomerID = @customerID

SELECT *
FROM Orders
WHERE CustomerID = @customerID
ORDER BY OrderID

I'm kind of lost as, so far, I've though of anything preceded by a '@' as a placeholder for user input. But, in the example above, it looks like '@companyName' is used as a regular variable like in C# for instance (SELECT @companyName = ...). But, @companyName is not known yet.

So, what the true nature a something preceded by a '@' like above? a vriable? a simple placeholder to accommodate user entered value?

Thanks for helping

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2008