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 2005 Forums
 Transact-SQL (2005)
 Query using Variable - DB2

Author  Topic 

rwaldron
Posting Yak Master

131 Posts

Posted - 2008-05-27 : 07:31:19
Hi all,
Sorry if this is the wrong place to ask but I have tried a few places with no joy.
In SQL when querying using a variable I can use @ symbol.
ie:
SELECT COUNT(*) FROM dbo.Persons WHERE SocialSecurityNumber = @SocialSecurityNumber
Then in say visual web developer this would prompt me to enter the variable for @SocialSecurityNumber
This all works perfect.
My issue is when I query a DB2 DB directly say
SELECT COUNT(*)
FROM DB2.table
WHERE (MMITNO = @MMITNO)
I get ther error "Column @MMITNO does not exist"
My question is. What symbol do I use to represent variable in DB2.
In SQL it is @ ..I think these symbols are known as sigils
Please Help
Ray..

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-27 : 08:16:06
You can use dynamic sql to build the query string if you connect to DB2 with linked server.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-05-27 : 08:18:27
I belive you can ask db2-questions at dbforums dot com

--
Lumbago
Go to Top of Page

rwaldron
Posting Yak Master

131 Posts

Posted - 2008-05-27 : 09:19:12
Hi all,
Just to let you know I got it working

SQL WHERE (MMITNO = @MMITNO)
DB2 WHEREMMITNO = ?)
Thx,
Ray
Go to Top of Page
   

- Advertisement -