sql query (dynamic/user input)

Discussion in 'Database Support' started by gurdip786, Jul 2, 2008.

  1. gurdip786

    gurdip786 Guppy

    i am tryin to write a sql select query that need input from user at runtime

    there is field with products which can have several entries -
    eg. grains,oil, steel

    I want my query to search all rows containing steel (user inputs at runtime)

    i need syntax please
  2. KrisSiegel

    KrisSiegel Perch

    Well, how do you plan to call this SQL? Do you want it in a stored proc or inline?

    You could do something like
    Code:
    SELECT * FROM Products WHERE Type = @Type
    
    A stored proc would be nice
    Code:
    CREATE PROCEDURE [MySchema].[GetProductListing]
    (
         @Type VARCHAR(24)
    )
    AS
    BEGIN
         SELECT * FROM Products WHERE Type = @Type
    END
    

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services