SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Passing a Fields Value Based on a Parameter Stored Procedure

    I have the following to create a stored procedure and it works fine, but I need to get the list of JobId's in the output without supplying parameters. Here is what I am trying to do:

    The parameter is automatically entered through code.

    CREATE
    PROCEDURE spSelectedJobs
    @id intOUTPUT
    AS

    SELECT
    id ,JobId
    FROM job_notify
    WHERE id = @id

    At this point I want to know what JobId's are selected by the user and create a query that excudes the JobId from a Job List, basically:

    SELECT JobId
    FROM city_jobs
    WHERE JobId <> JobID_From_SELECT_STATEMENT_ABOVE

    This would provide a list of jobs that the user has not selected.



    Any thoughts. I have tried creating a function as well, but so far, no luck.

    Thanks.


    Chris

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    1) Don't prefix stored procs with sp, the system uses that to denote system stored procs, so it ends up looking in MASTER before looking at your database.

    2) Why are you using an output parameter?

    3) I'm having trouble following the question, but I think what you need to do something like:

    Code:
    SELECT Job_Id
    FROM City_Jobs
    WHERE Job_Id NOT IN (
       SELECT Job_Id
       FROM job_notify
       WHERE id = @id)


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •