parameter prompt in select statement

  • I'm trying to create a simple select statement that will allow me to prompt whoever is running it to enter search criteria in a prompt. Can this be done?

    SELECT count(*) from table1 where field1 = ;

    I'm using sybase : ISQL and I am finding it does not like he ampersand & or the pound sign # I've seen used in other samples to prompt the user for information.

  • Can't say I know how to do this in Sybase, if it's different from SQL Server, but how you'd do it in SQL Server is generally with a stored procedure:

    create proc Counter

    (@Field1_in int)

    as

    SELECT count(*) from table1 where field1 = @Field1_in;

    (That example assumes that Field1 is an integer data type.)

    To get the data from this, you'd run:

    exec dbo.Counter 1

    With "1" being the number you want to run.

    There's more to it, but that's a basic introduction.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply