Solved

Linq inside SQL server ?

Posted on 2012-04-11
1
323 Views
Last Modified: 2012-04-17
Hello EE,

Lets say I have a query like this:

SELECT a.ID, a.Description,
[answer] = CASE WHEN a.ID=1 THEN 'Something'
    ELSE ( SELECT sum(x.Amount) END

FROM Table1 a
LEFT JOIN Table2 x on x.ID = a.ID
WHERE x.currentYear = 2011


ok my question is...
lets I would like to include a WHERE clause saying  where x.period = 10

is it possible to write that clause inside the Case when on the select? do to it like this:

ELSE ( SELECT sum(x.Amount) where x.Period = 10 )... ?

I  know i could write the clause after my left join but i need to know if there is a way to do like in vb.net some LINQ?

i hope my question is clear...
thanks
0
Comment
Question by:PhilippeRenaud
1 Comment
 
LVL 9

Accepted Solution

by:
keyu earned 500 total points
ID: 37836976
Hi,

Have a look with this article might helps you.

http://geekswithblogs.net/CodePersona/archive/2008/01/03/118232.aspx

http://www.linqpad.net/

Thanks,
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

809 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