Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable passing

Status
Not open for further replies.

murzina

Programmer
Jan 14, 2009
14
What is the syntax in SQL Express for passing a variable,
for instance,

Declare @@number decimal
begin
print '@@number'
end

What is wrong with this coding?
 
Usually, variables have a single @ symbol, but there's nothing wrong with having 2 of them.

If you want to print the value of @@number, remove the single quotes. In this case, you don't initialize @@number with any value, so it is null. Since you cannot print NULL, you see nothing in the output. While you are at it, I encourage you to use a precision and scale value when using a decimal data type.

Code:
Declare @@number decimal(20,10)
Set @@number = 3.1415926536

begin
print @@number
end


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
using @@. Only one @ sign is used for variables:
Also you didn't set any value to this variable. So try this:
Code:
DECLARE @number decimal(10,2)
SET @number = 10.25
print @number



Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Boris,

Just for fun, what do you think the output of the code would be?

Code:
Declare @ VarChar(30)
Declare @@ Varchar(30)

Set @ = 0x52616365636172
Set @@ = Reverse(@)

Print @
Print @@


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Hmmm, varchar and binary,
I don't know what char stay for ASCII code 0x52, 0x61 etc. So I assume that some word will appear :) and after that you will get the same word reversed :)
but I don't like the code :)))))))
just @ and @@ w/o names, GRRRR!

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
you will get the same word reversed

Are you sure? [wink]


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Yeah,
The same word reversed (the Capitial letter is at the end :)
(I tested it already and I new what stays for 0x52)
Racecar
racecaR
If you used:
Set @ = 0x72616365636172
Then both words would be the same :)
(but I got this after testing the code :))

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top