CREATE Procedure sp_Select_Selling_Test @ StkList_Id varchar (30), @ Bill_Sta tinyintasdeclare @StrSql nvarchar (250) Set @StrSql = '' if len (ltrim (rtrim (@StkList_Id)))> 0 Begin Set @ StrSql = @ StrSql 'And StkList_Id Like ''% ' @stklist_id '% '' end
IF @bill_sta> 0begin set @ strsql = @ strsql 'and bill_sta =' rtrim (Ltrim (Strim (@bill_sta))))
Endset @ strarsql = 'select * from stocks_sell_data where stklist_id <>' '' '' @strsqlexec sp_executesql @ strsqlgo // call exec sp_select_selling_test '050128xs-003', 1
============================================================================================================================================================================================================= =====================
Create Procedure SP_Product_Search @Product_code nvarchar (20), @ Sale_price real asclare @STRSQL NVARCHAR (200) set @ strsql = ''
If LTRIM (@Product_code))> 0 beginset @ strsql = @ strsql 'and product_code limited "%' LTRIM (RTRIM (@Product_code)) '%" ""
If isnumeric = 1beginset @ strsql = @ strsql 'and sales_price <' cast (@sale_price as nvarchar (10)) // Digital type To convert to a character type END
Set @ strsql = 'select * from products where (ProID <> 0)' @strsqlexec sp_executesql @strsqlgo
//transfer
EXEC SP_PRODUCT_SEARCH 'L', 22
========================================== // Take Output parameters
Create Procedure SP_Product_Search @Product_code nvarchar (20), @ sale_price real, @ aa nvarchar (200) Output asclare @strsql nvarchar (200) set @ strsql = ''
If LTRIM (@Product_code))> 0 beginset @ strsql = @ strsql 'and product_code limited "%' LTRIM (RTRIM (@Product_code)) '%" ""
IF isnumeric = 1beginset @ strsql = @ strsql 'and sales_price <' cast (@sale_price as nvarchar (10)) End
Set @ strsql = 'select * from products where (ProID <> 0)' @strsqlset @AA = @strsqlexec sp_executesql @strsqlgo
///transfer
Declare @AA As nvarchar (200) Exec sp_product_search 'L', 22, @ aa outputprint @AA
====================================