473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Addition of two numbers

1) DECLARE @num1 int , @num2 int
Above statement declares two variables num1 and num2.

I want the addition of two numbers--
SET @num1=10
Error-Must declare the scalar variable "@num1".

2) DECLARE @num1 int =10, @num2 int= 20
is it possible to initialise the variables in the declaration as in the above case.
Feb 18 '08 #1
8 12134
Delerna
1,134 Expert 1GB
1) are you saying that you have these 2 lines of code
Expand|Select|Wrap|Line Numbers
  1. DECLARE @num1 int , @num2 int
  2. SET @num1=10
  3.  
and you are getting this error
Error-Must declare the scalar variable "@num1".

if so then I am staring and staring at the lines and I can't for the life of me see anything wrong with them. The error is saying you havn't declared the variable @num1

Where have you written those two lines? In a stored proc, In query analyser or where ???

2) No, I dont think so. But try and see, you will get an error if you can't
Feb 18 '08 #2
Query Analyzer......
Error is there u can check it out by executing it ......

Triggers are also known as Stored procedures na........
Feb 18 '08 #3
Delerna
1,134 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. DECLARE @num1 int , @num2 int
  2. SET @num1=10
  3.  
Nope, it works fine for me in query analyser ???
Feb 18 '08 #4
In SQL Server 2000,Query Analyzer and Enterprise Manager are different.
But in SQL Server 2005,there is only one window where on the LEFT HAND SIDE,u r able to view all ur tables, and on the RHS,u write query.


U R working on SQL 2000 or 2005??

I m working on SQL Server 2005.
Feb 19 '08 #5
Delerna
1,134 Expert 1GB
I have not had the pleasure of using SQL 2005 as yet, I use 2000.
Feb 19 '08 #6
ck9663
2,878 Expert 2GB
In SQL Server 2000,Query Analyzer and Enterprise Manager are different.
But in SQL Server 2005,there is only one window where on the LEFT HAND SIDE,u r able to view all ur tables, and on the RHS,u write query.


U R working on SQL 2000 or 2005??

I m working on SQL Server 2005.

Click New Query. Paste your code on the query window. Click execute (or press F5)

-- CK
Feb 19 '08 #7
Hey Ck,Can u please tell me how to add two numbers ?????
Feb 20 '08 #8
Hey Ck,Can u please tell me how to add two numbers ?????
try this..

Declare @cnt01 int, @cnt02 int
set @cnt01=10
set @cnt02=10
select @cnt01+@cnt02
Feb 20 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Mathieu Malaterre | last post by:
Hi, I tried a simple addition with python and I don't understand what is going on: $python >>464.73+279.78 744.50999999999999 weird isn't it ? I use python2.3.
7
by: jeffbernstein | last post by:
Greetings. I'm reading "How to think like a computer scientist: Learning with Python" and there's a question regarding string operations. The question is, "Can you think of a property that...
3
by: Jay | last post by:
I have two strings that instead of adding them together to get the sum the are concatenating together. Does anyone know how I can get these two to add. while not rstemp4.eof vservdate =...
8
by: Matt | last post by:
Hello, How can I do mathematical addition of strings in C++? As in: string one; string two; string three; three = one + two;
2
by: akickdoe22 | last post by:
i could really use help finishing this addition program. I'm stuck on the part that allows you to add any two large integers,up to 100 digits,(pos+pos, neg+neg, and pos+neg). could use hints ideas...
23
by: Alex Vinokur | last post by:
Consider the following statement: n+i, where i = 1 or 0. Is there more fast method for computing n+i than direct computing that sum? -- Alex Vinokur email: alex DOT vinokur AT gmail DOT...
8
by: Rene | last post by:
The following code: float someFloat = 0; for(int x = 1; x <= 10; x++) { someFloat += .1F; Console.WriteLine(someFloat.ToString()); }
3
by: snow.carriers | last post by:
Let me first state that I'm using Borland Turbo C++, it's relatively old so the new string methods won't work. Anyways, first I'm trying to collect a line of a string (with numbers, letters,...
5
by: Paul | last post by:
Why is the addition here adding the number as a string but the subtraction works fine? function boxchange(box) { iv= dbform.ut.value if (box.checked == true) { iv = iv - box.value } else {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.