0 Replies Latest reply on Oct 16, 2012 6:37 AM by 968550

    How can I make this to display any either variable that I input?

    968550
      I want it to display either one of the variable or all of the variable or 2 of the variables when i execute it...How can I do that?Anyone Pls help...



      declare @sql varchar(8000)
           declare @sql_where varchar(8000)
           
           declare @ww varchar(10)
           declare @plant varchar(10)
           declare @plnr_id varchar(10)

           set @plant = 'CS58'
           set @ww = '201240'     
           set @plnr_id = 'G37'
           
           set @sql_where = ''
           set @sql = 'select * from rout_sub_doi '
           
           if len(@plant) > 0
                set @sql_where = 'where plant = ''' + @plant + ''' '
           
           if len(@ww) > 0
                set @sql_where = @sql_where + 'AND sys_intel_ww = ''' + @ww + ''' '
           
           if len(@plnr_id) > 0
           
                set @sql_where = @sql_where + ' AND plnr_id = ''' + @plnr_id + ''' '
           
                
           print @sql
           print @sql_where
                
           exec (@sql + @sql_where )

      Edited by: 965547 on Oct 15, 2012 11:37 PM