Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Declaring and setting Variables

Author  Topic 

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2009-12-07 : 10:49:59
DECLARE @OrderItemID int
DECLARE @CustomerID int

@OrderItemID = 9243578
@CustomerID = 1299539

what the heck is wrong with this...it's saying that the syntax is not right.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-07 : 10:55:52
You need to SET it..ot SELECT the value...

like
DECLARE @OrderItemID int 
DECLARE @CustomerID int

SET @OrderItemID = 9243578
SET @CustomerID = 1299539

SELECT @OrderItemID,@CustomerID
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-12-07 : 10:57:55
You've posted in T-SQL (2008) so this is also possible:

DECLARE @OrderItemID int = 9243578




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2009-12-07 : 11:06:32
quote:
Originally posted by vijayisonly

You need to SET it..ot SELECT the value...

like
DECLARE @OrderItemID int 
DECLARE @CustomerID int

SET @OrderItemID = 9243578
SET @CustomerID = 1299539

SELECT @OrderItemID,@CustomerID




Doh, thanks!
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-07 : 12:01:15
np..it happens
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-08 : 01:50:10
quote:
Originally posted by CoffeeAddict

DECLARE @OrderItemID int
DECLARE @CustomerID int

@OrderItemID = 9243578
@CustomerID = 1299539

what the heck is wrong with this...it's saying that the syntax is not right.


Become SqlAddict

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -