Professional Web Applications Themes

Stored procedure questions - Microsoft SQL / MS SQL Server

hi guys, I have this stored procedure: CREATE PROCEDURE newClient StartDate datetime, EndDate datetime, cManager nvarchar(20) AS Select 'Total ' as [NEW CLIENT], count (ClientID) as total FROM [Client Intake] where Manager=cManager AND Date>=StartDate AND Date<=EndDate I want it to return all new client for ALL Manager if the user doesn't supply cManager. How can I do this? I've tried to set the defult value for cManager to *, and it doesn't work. Thanks in advance....

  1. #1

    Default Stored procedure questions

    hi guys,
    I have this stored procedure:
    CREATE PROCEDURE newClient
    StartDate datetime,
    EndDate datetime,
    cManager nvarchar(20)
    AS
    Select 'Total ' as [NEW CLIENT], count (ClientID) as total
    FROM [Client Intake]
    where Manager=cManager AND Date>=StartDate AND Date<=EndDate

    I want it to return all new client for ALL Manager if the user doesn't
    supply cManager.
    How can I do this?
    I've tried to set the defult value for cManager to *, and it doesn't work.
    Thanks in advance.




    Junaili Lie Guest

  2. #2

    Default Re: Stored procedure questions

    JL> hi guys,
    JL> I have this stored procedure:
    JL> CREATE PROCEDURE newClient
    JL> StartDate datetime,
    JL> EndDate datetime,
    JL> cManager nvarchar(20)
    JL> AS
    JL> Select 'Total ' as [NEW CLIENT], count (ClientID)
    JL> as total FROM [Client Intake]
    JL> where Manager=cManager AND Date>=StartDate AND
    JL> Date<=EndDate

    JL> I want it to return all new client for ALL Manager
    JL> if the user doesn't supply cManager.
    JL> How can I do this?

    set cManager default value to NULL and then

    where manager=isnull(cManager,Manager)
    Vadim Rapp Guest

  3. #3

    Default Stored procedure questions

    Use Manager like cManager in the where clause. Use % as
    the wildcard, not *.
    Kiril
    >-----Original Message-----
    >hi guys,
    >I have this stored procedure:
    >CREATE PROCEDURE newClient
    >StartDate datetime,
    >EndDate datetime,
    >cManager nvarchar(20)
    >AS
    >Select 'Total ' as [NEW CLIENT], count (ClientID) as total
    >FROM [Client Intake]
    >where Manager=cManager AND Date>=StartDate AND
    Date<=EndDate
    >
    >I want it to return all new client for ALL Manager if the
    user doesn't
    >supply cManager.
    >How can I do this?
    >I've tried to set the defult value for cManager to *, and
    it doesn't work.
    >Thanks in advance.
    >
    >
    >
    >
    >.
    >
    Kiril Guest

Similar Threads

  1. Stored Procedure
    By Aaron Bertrand - MVP in forum ASP.NET
    Replies: 13
    Last Post: July 5th, 05:43 AM
  2. Stored procedure?
    By SG via DotNetMonster.com in forum ASP.NET Web Services
    Replies: 0
    Last Post: February 23rd, 01:06 PM
  3. Questions on stored-procedure best practices
    By Eric Brown in forum PostgreSQL / PGSQL
    Replies: 1
    Last Post: December 11th, 08:42 PM
  4. Stored procedure from stored procedure
    By Red Valsen in forum Informix
    Replies: 3
    Last Post: October 2nd, 02:22 PM
  5. need help on a stored procedure
    By Helixpoint in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: July 8th, 01:26 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139