Solved

Variables in a view

Posted on 2004-08-28
3
202 Views
Last Modified: 2010-04-23
I need to select records for a Crystal Report.  I thought the best way was to create a view - i need to select records based on their shipment number - my code is below and the question follows:
--------------
DECLARE @ship char(5);
SET              @ship = '1012';
                          SELECT     dbo.tblShipments.id AS ShipNum, dbo.tblShipments.Destination AS Destination, dbo.tblShipments.Date AS ShipDate,
                                                  dbo.tblShipmentData.palletid AS Pallet, dbo.tblShipmentData.tubcode AS Product, dbo.tblShipmentData.qty AS qty,
                                                  dbo.tblShipmentData.dateprod AS DateProd
                           FROM         dbo.tblShipments RIGHT OUTER JOIN
                                                  dbo.tblShipmentData ON dbo.tblShipments.id = dbo.tblShipmentData.shipnum
                           WHERE     (dbo.tblShipments.id = @ship)
---------------------
Now, how, in VB or Chrystal, so i pass the current @ship value to the view????
0
Comment
Question by:jakyll
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11922412
you wouldnt do that ...

you would either use a stored procedure and pass a parameter or use ...

view ...
                          SELECT     dbo.tblShipments.id AS ShipNum, dbo.tblShipments.Destination AS Destination, dbo.tblShipments.Date AS ShipDate,
                                                  dbo.tblShipmentData.palletid AS Pallet, dbo.tblShipmentData.tubcode AS Product, dbo.tblShipmentData.qty AS qty,
                                                  dbo.tblShipmentData.dateprod AS DateProd
                           FROM         dbo.tblShipments RIGHT OUTER JOIN
                                                  dbo.tblShipmentData ON dbo.tblShipments.id = dbo.tblShipmentData.shipnum

SELECT * from YourViewName where ShipNum = '1012'
0
 

Author Comment

by:jakyll
ID: 11922710
oh!
Thank you - I didn't understand how to use views.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11923052
no worries ...

Let me know if you require any further help.

Cheers,

Greg
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now