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 2000 Forums
 SQL Server Development (2000)
 PARAMETER in Query Analyzer

Author  Topic 

cardgunner

326 Posts

Posted - 2007-06-25 : 09:58:25
I'm used to MS Access where as putting "[" s around a question would then prompt that question when you ran the query. You would type in the answer and that answer was then then part of the criteria for your query.

I looked on bol and they said that i could just use a "?" or use "%" to surround the question. That doesn't work. I get
[Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error

What am I doing wrong?

Card Gunner

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-06-25 : 10:01:39
show us your query.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-25 : 10:04:46

Post your question at Access Forum

Madhivanan

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

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-25 : 10:05:49
If you are using ? in QA to get the same interactivity you get in MS-Access, be clear that QA does not have that kind of facility for SQL Server. You can set the parameter values manually and run the script.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cardgunner

326 Posts

Posted - 2007-06-25 : 10:36:49
Spirit
select BUYID,
BPID,
BUYCOMP1,
BUYADR1
FROM QRY9962
WHERE BUYID=?

madhivanan
I don't need to post it on MS Access cause I know it works there. I can do it in Access. I don't know how to do it in SQL

Harsh
QA does not have the type of interactivity? So if I have a an update that I need to do over and over with different ID's I need to go into the script and change it. That is not a big deal it is just cleaner when there is a prompt for an answer.

Like I said if it's not available in QA - OK, not a problem- I'm moving on.

Thank you all very much. I hope I'm not abusing this forum. I find it very helpful. I do try to find my answer out there before I post.

Again thank you.


Card Gunner
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-06-25 : 10:57:45
you have to do this with a parameter:

declare @BUYID int -- it must be the same datatype as your column
select @BUYID = 5 -- set the value to something

select BUYID,
BPID,
BUYCOMP1,
BUYADR1
FROM QRY9962
WHERE BUYID = @BUYID

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-26 : 01:13:15
<<
I don't need to post it on MS Access cause I know it works there. I can do it in Access. I don't know how to do it in SQL
>>

SQL Server wont prompt you to enter values
Make use of parameters as suggested

Madhivanan

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

- Advertisement -