Select Procedure

  • The information is being return from the same table but is presently being returned as an int. The int is being submitted into the table from a dropdown list as a new request.

    I want to be able to show the text value of the other table whichs relates to 0, 1, 2 etc...

    if you know what i mean?

    Mick

  • That's what I mean, you need to know where that table is, make an inner join to it and present the right data.

    You need to learn this to be autonome, so I'll let you hack at it.

    let us know what you tried, what problems you are having (assuming you don't understand the help file, which would be very surprising to me).

  • In addition to the help file, you should consider picking up a copy of Itzik Ben-Gan's new book, T-SQL Fundamentals. It'll get you pretty far down the track pretty quickly.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Here's a slightly different take. This method makes the @UID parameter optional and sets it to NULL initially. If you don't have a UID simply don't pass it.

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[select_NewRequest]

    @UID INT = NULL

    AS

    IF @UID IS NOT NULL

    BEGIN

    SELECT

    [UID]

    ,[StaffNumber]

    ,[BusinessReason]

    ,[Requirements]

    FROM

    [MobilePhones].[dbo].[tblPersonRequestDetails]

    WHERE

    [UID] = @UID

    END

    ELSE

    BEGIN

    SELECT

    [UID]

    ,[StaffNumber]

    ,[BusinessReason]

    ,[Requirements]

    FROM

    [MobilePhones].[dbo].[tblPersonRequestDetails]

    END

    GO

  • It'll still result in poor performance and recompiles. I still think the better approach is a wrapper proc calling x number of other procedures.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 5 posts - 16 through 19 (of 19 total)

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