Results 1 to 3 of 3

Thread: Passing Parameters to a View

  1. #1
    Join Date
    Sep 2002
    Posts
    5

    Passing Parameters to a View

    Can I pass a parameter to a view? Can something like this even be done?

    CREATE view co_interlinks1
    AS
    SELECT [TDirectorships].[IDDir], [TDirectors].[DirLName] + ', ' + [TDirectors].[DirFName] AS DirectorName, [TDirectorships].[Ticker], [TCompanies].[CompanyName]
    FROM TDirectorships
    INNER JOIN TCompanies
    ON [TCompanies].[Ticker]=[TDirectorships].[Ticker]
    INNER JOIN TDirectors
    ON [TDirectorships].[IDDir]=[TDirectors].[IDDir]
    WHERE [TDirectorships].[IDDir] in (SELECT [TDirectorships].[IDDir]
    FROM TDirectorships
    WHERE Ticker=@Ticker) --This line requires a variable value corresponding to Ticker for the chosen company
    and [TDirectorships].[Ticker] <> =@Ticker --This line requires a variable value corresponding to Ticker for the chosen company

  2. #2
    Join Date
    Sep 2002
    Posts
    169
    You cannot pass parameters to views. You can either treat the view link a table and use a where clause or if you really want to use parameters, you will need to create a function.

    Cheers
    Stephen

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254

    Cool

    Why cant you create this as a procedure and pass parameters?

Posting Permissions

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