Dzyner
Starting Member
1 Post |
Posted - 2012-06-29 : 10:12:12
|
Hi all,I'm trying to export data to a fixed width file through import export wizard and saving it to a SSIS package. I'm getting "must declare scalar variable @where" and must declare scalar variable @what. The code is as follows:ALTER PROCEDURE [teppermans].[rpt_DMS_CUSTORDS]@Where Varchar(5) = 'A'as DECLARE @What TABLE (ID VARCHAR(50) NOT NULL)IF @Where = 'F' BEGIN INSERT INTO @What (ID) VALUES ('BK'),('BR'),('CH'),('DE'),('DR'),('LA'),('LE'),('MO'),('SB'),('TA'),('UP')END ELSE IF @Where = 'A' BEGIN INSERT INTO @What (ID) VALUES ('AP'),('AV'),('AX'),('BE'),('DW'),('DY'),('FI'),('FR'),('MW'),('PP'),('RA'),('RE'),('ST'),('TV'),('VC'),('WA'),('AC')END ELSE BEGIN INSERT INTO @What (ID) VALUES ('AP'),('AV'),('AX'),('BE'),('DW'),('DY'),('FI'),('FR'),('MW'),('PP'),('RA'),('RE'),('ST'),('TV'),('VC'),('WA'),('BK'),('BR'),('CH'),('DE'),('DR'),('LA'),('LE'),('MO'),('SB'),('TA'),('UP'),('AC')END SELECT tbl1.ProductID MODEL ,tbl1.ShipLocnID LOCN ,tbl1.QtyOrdered QTY ,tbl1.OrderID ,tbl2.ShipToName CUSTOMER ,tbl1.DlvyStatus EstSch ,tbl2.OrderDateFROM storis.OrderItem tbl1JOIN (SELECT OrderID,ShipToName,OrderDate FROM storis.Orders) tbl2ON tbl1.OrderID = tbl2.OrderIDWHEREtbl1.ProductTypeID IN ('1','4','6')ANDtbl1.TransCodeID IN ('00','60','63')ANDtbl1.OrderItemType <> '3'ANDtbl1.RecStatus <> 'D'ANDtbl1.SourceID = '01'andtbl1.CategoryID IN (SELECT ID FROM @What) any help please???Kevin P. Mayea I Assistant Project Manager I Tepperman's I 2595 Ouellette Avenue I Windsor, Ontario N8X 4V8 I 519-969-3063 ext 1480 I 519-982-7269 | kmayea@teppermans.com I www.teppermans.com |
|