Solved

how to assign default value to a parameter

Posted on 2014-09-08
1
148 Views
Last Modified: 2014-09-08
I need to set a default value to the the following parameters in my SQL query so that I do not have to pass them in via a form.
@gbloptState AS VARCHAR(4) ,   = 4-
@InsPrfCrdLtrOpt AS VARCHAR(1) = 1

Query

USE [EXPORTmdhpixPROD]
GO
/****** Object:  StoredProcedure [dbo].[InsProfile_CredLetter_Parm]    Script Date: 9/8/2014 8:49:17 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
/* ***************************************************************************************************/
/*              Insured Profile & Credentialing Letter                                                              */
/* **************************************************************************************************/

ALTER PROCEDURE [dbo].[InsProfile_CredLetter_Parm]
    (
      @gbloptState AS VARCHAR(4) ,
      @InsPrfCrdLtrOpt AS VARCHAR(1)
    )

AS
    SET NOCOUNT ON
    SELECT DISTINCT
            IC.LicenseNumber AS [License Nbr] ,
            RM.City AS City ,
            RM.State AS state ,
            RM.Zip AS zip ,
            Insured ,
            IC.GroupName AS GroupFirmName ,
            SUBSTRING(IC.Policy, 1, CHARINDEX('-', IC.Policy)) AS PolPrefix ,
            RM.Addr1 ,
            RM.Addr2 ,
            RM.Addr3 ,
            RM.Fax ,
            InsuredName = CASE WHEN RM.FirstName = ' ' THEN RM.LastName
                               ELSE RM.FirstName + ' '
                                    + CASE WHEN ISNULL(RM.MiddleInitial, ' ') = ' '
                                           THEN RM.LastName + ' '
                                           ELSE RM.MiddleInitial + ' '
                                                + RM.LastName + ' '
                                      END
                                    + CASE WHEN ISNULL(RM.Title, ' ') = ' '
                                           THEN RM.Designation
                                           ELSE RM.Title + ' '
                                                + RM.Designation
                                      END
                          END
    FROM    InsuredCov_All IC
            INNER JOIN wellandp.ReferMaster RM ON 'A' + IC.LicenseNumber = RM.ReferKey
    WHERE   ( LEFT(RM.ReferKey, 1) = 'A' )
            AND ( IC.SlotType <> 'S' )
            AND ( dbo.IsTail(IC.RiskType) = 'N' )
            AND ( @gbloptState LIKE '%99%'
                  OR SUBSTRING(IC.Policy, 1, CHARINDEX('-', IC.Policy)) = @gbloptState
                )
            AND ( ( @InsPrfCrdLtrOpt = '1' )
                  OR ( @InsPrfCrdLtrOpt = '2'
                       AND dbo.IsEPLI(IC.RiskType) = 'N'
                     )
                )
    ORDER BY insured
0
Comment
Question by:mburk1968
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 50

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40309910
Just set the value that you want in the parameter definition:

ALTER PROCEDURE [dbo].[InsProfile_CredLetter_Parm]
     (
       @gbloptState AS VARCHAR(4)  = '4',
       @InsPrfCrdLtrOpt AS VARCHAR(1) = '1'

.
.
.

Open in new window

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question