?
Solved

Need help with a sql view

Posted on 2012-08-16
3
Medium Priority
?
428 Views
Last Modified: 2012-08-20
I am using the following query:

SELECT        a.pkNewTargetID, a.ProductClass, a.Product_ProductServiceName
FROM            Target AS a LEFT OUTER JOIN
                         TargetReference AS b ON a.Product_ProductServiceName = b.ProductServiceName amd b.fk_PlanID='30'
WHERE        (b.ProductServiceName IS NULL) AND (a.Letter = 'Y')

This query is intended to show all records from target that are not in TargetReference that are assigned to that paticular fk_PlanID.  I can get the query to work in design view however when I put it into a view I cannot populate that '30' using a linqdatasource. Please help.
0
Comment
Question by:mwhodges
3 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 38302222
>b.ProductServiceName amd b.fk_PlanID='30'
typo, amd should be AND

>b.fk_PlanID='30'
should this be a.fk_PlanID?
0
 

Author Comment

by:mwhodges
ID: 38302245
Yes sorry.  I made the correction after I posted.
0
 
LVL 31

Accepted Solution

by:
MlandaT earned 2000 total points
ID: 38304192
I take it the issue here is really about figuring out how to filter when using a LinqDataSource. In general, you can filter the returned data to retrieve only the records that meet particular criteria by setting the LinqDataSource's Where property to the conditions that must be met for a record to be included in the returned data.

You can do this by parameterising the Where clause (to pick up values from controls automatially as shown under the "Creating a Parameterized Where Clause" section on this page http://msdn.microsoft.com/en-us/library/bb547113.aspx. If you want to do it programmatically... then see if this article helps: http://www.yanachik.org/2008/02/28/how-to-dynamically-set-a-linqdatasource-to-filter-the-results-based-on-user-input/
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

850 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