Solved

Variables in a view

Posted on 2004-08-28
3
209 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:Dan Flood
[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
  • 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:Dan Flood
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System.net.Sockets Error 5 47
vb.net Configuration, settings file location? 8 61
Create a button class for use in all vb.net apps 5 40
Select coumns form Data table? 3 22
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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