.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Need query to refine my result set

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :Sql Server

I have 2 tables which contains say Student Information & Marks Information. Now i have used a JOIN to get result as below.

StudentID StudentName Subjects Marks
1 Ricky Maths

View Complete Post

More Related Resource Links

Use DB query result to generate Jquery required lines of code



I 'm gonna query database for photo records. each record include "photo path" where imagesURL  stored in string format

 I Choses my favorite Juqery plugin to show images. Plugin needs some lines of code like below.

How could I  generate these lines

$(function() {
sleep: 2,
fade: 1
}, [
{ src: 'picture1.jpg' },
{ src: 'picture2.jpg' },
{ src: 'picture4.jpg' }

On New Item form, select item on choice dropdown based on query result.


I posted this on Experts Exchange awhile back with no answer, so here's hoping someone here has an idea :)

So I've mostly figured this problem out, but I need some help in getting over the hump... note that I'm using JavaScript to do this (SPServices) on SharePoint 07'.

I'm on the New Items page of a list. Based on a user's selection in a "Teacher" dropdown, I'm doing the following:

1.) Get the value of the Teacher field and several other fields (School and Visit Date)
2.) Run a CAML query based on those fields to find the last list item entered for that Teacher

So here's where I'm stuck...

I have 10 choice fields, all with choices 0, 4, 7, and 10. Depending on what they were set to in the last entered item (which I queried), I want to set the selected item on each of those dropdowns to equal that. So "Score 1" was set to "4" on the la

Dynamic Class with Linq query Result

Hi, var   query = db.Customers.Where( "City == @0 and Orders.Count >= @1", "London", 10). OrderBy( "CompanyName"). Select( "New(CompanyName as Name, Phone)");    I am using this query as a sample which returns a dynamicclass type, and i need this should to converted to a list collections or datatable etc., As i am holding it in my wcf service with linqtosql as dataaccesslayer. Trying to send the results to the UI which i have consumes this service. Kindly help me in this. Thanks query = db.Customers

Need to add hard coded values to LINQ query result

I am running a LINQ query which populates a list used by a DropDownList, I need to insert an "Unassigned" value to the list. The function below queries the values correctly from the db but does not insert the "Unaasinged" value to the list. Please help.   public List<KeyValuePair<int, string>> GetTestList() { KeyValuePair<int, string> item = new KeyValuePair<int, string>(0, "Unassigned"); using (DataClassesDataContext db = new DataClassesDataContext()) { var Query = from records in db.TEST_SUITEs orderby records.TEST_SUITE_ID select new KeyValuePair<int, string> ( records.TEST_SUITE_ID, string.Format(records.TEST_SUITE_ID + " " + records.SUITE_TYPE + " " + records.SUITE_NAME) ); //Query.ToList().Insert(0, item); Query.ToList().Insert(0,item); return Query.ToList(); } }  

Check if Linq query return result

HelloI have Linq query likeDim Prood= (From p InProdutcts _                                          where p.ProductID="InputInteger"                                                         ..... ) .SingleOrDefaultI could Use Count if I Use .ToList Instead of .SingleOrDefault , But now that I use 'SingleOrDefault', how Could I find if Prod contains any record or it's Empty.

SQL server management studio 2008 freezes when running a query to Grid result

Hello, I've got problems when I run a Query to a grid result using SQL server management studio 2008 under W7 pro. When I execute the query, the first part of the grid returns, but then it freezes. The query should present a double resultset and contains approx 6100 records, devided over 2 grids. Strange enough, the query runs fine when I export to TXT or to a file. It seems though that the problem is building the grid. When it occurs I cannot end the application bij shutting down de SSMS window, but have to kill the Ssms.exe. In task manager I see only 25% CPU usage and approx 20% memory usage. Nothing exiting there I guess. Suggestions anybody? Microsoft SQL Server Management Studio      10.0.2531.0 Microsoft Analysis Services Client Tools      10.0.3798.0 Microsoft Data Access Components (MDAC)      6.1.7600.16385 Microsoft MSXML      3.0 4.0 5.0 6.0 Microsoft Internet Explorer      8.0.7600.16385 Microsoft .NET Framework      2.0.50727.4952 Operating System      6.0.6001 regards, Pim

Analysis Services - Query returns a #error result

Hi, I have a cube - which i had backed up and just retored it. After the restoration, when i try to reply the cube e.g: select [Time].&[200503] on 0 , {[Process].[All process]} on 1 from [myConsolidations] - i recieve an a result showing #error only. What could be the cause of this?

Exporting my query result to .CSV or .Txt fomat?

Hi everyone, i would like to ask if there is way on how to export my query result into .csv or .txt file?   Thanks

How to setup Query Result Shaping for LinQ to SQL instead of Entity Framework?

Hi, I am new to this, and I am trying to implement a linq query similar to db.Genres.Include("Albums") command from mvc music store using my current DB setup. I realize that the tutorial mentions Checlking the "Include foreign key columns in the method" when creating the tables in ADO.NET, but if I am using LINQ to SQL classes, then how can I obtain the same effect. And how do I use db.Genres.Include("Albums") to simplify my life? Thanks

How to copy column headers along with the query result in SS00

HiIs it possible to copy the column headers along with the query result from SQL Server 2000 Query Analyser.Thanks in advance.fjz

Split query result to text


Dear Friends,

I Have problem with query result with split from sql server,

ex:   select * from RefCustType

in the table RefCustType:

code name location telp


in the query result in text file I want this ersult like:

"code","name","location","telp"               <- field name

"111","ucok","rusia","622192356"           <- record

"222","fery","depok","6235145"              <- record


thank's B4 for your help.

sorry my english is not very well.

Push MDX query result to SQl table with & in caption of members

Hi all,

I am trying to push the results of the MDX query to a sql server table using linked server. The MDX query by itself executes fine. But, the openquery fails because some of the members have the character '&' in them.If I remove those members having & in the caption from the query, I am able to do the insert the remaining members successfully. Can anyone guide me on how to successfully insert the data including the members with '&' symbol in their caption.

Thanks in advance,

Help :Is this Query right? How to Get the Result: Which to use union OR join AND How?

Can you please help me?


SELECT COUNT(T1.ID) AS T1_COUNT,convert(date,DATEADD(dd, 7-(DATEPART(dw, T1.TIME)), T1.TIME),101) AS T1_TIME FROM TABLE_1 AS T1,TABLE_2 AS T2 WHERE T2.ID=T1.ID AND T1.STATE != 'C' AND T1.TIME BETWEEN '2010-01-01 00:00:00' AND '2010-09-25 23:59:59' AND PRTY='F' GROUP BY convert(date,DATEADD(dd, 7-(DATEPART(dw, T1.TIME)), T1.TIME),101) ORDER BY T1_TIME DESC

T1_COUNT ---------- T1_TIME
3 ---------------- 2010-09-25
4 ---------------- 2010-09-18
2 ---------------- 2010-09-11


SELECT COUNT(T1.ID) AS T2_COUNT,convert(date,DATEADD(dd, 7-(DATEPART(dw,T1.TIME)), T1.TIME),101) AS T2_TIME FROM TABLE_1 AS T1,TABLE_2 AS T2 WHERE T2.ID=T1.ID AND T1.STATE != 'C' AND T1.STATE ='E' AND T1.TIME BETWEEN '2010-01-01 00:00:00' AND '2010-09-25 23:59:59' AND PRTY='F' GROUP BY convert(date,DATEADD(dd, 7-(DATEPART(dw, T1.TIME)), T1.TIME),101) ORDER BY T2_TIME DESC

T2_COUNT ---------------- T2_TIME
1 ---------------- 2010-09-25
2 ---------------- 2010-09-18

Sample Query:

how to store query result in variable


hello experts..

i am wishing to store the query result in any variable, please have look at below code.


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then

Dim conn As New SqlConnection(GetConnectionString())
Dim str As String = System.Web.HttpContext.Current.Request.Url.AbsolutePath
Dim previous = "SELECT views FROM Articles WHERE ([url]=@str)"
previous = previous + 1
Dim sql As String = "INSERT INTO Articles (views) VALUES (@previous)"
Dim cmd As New SqlCommand(sql, conn)
Dim pram As SqlParameter() = New SqlParameter(1) {}
pram(0) = New SqlParameter("@previous", SqlDbType.VarChar, 50)

pram(0).Value = previous

For i As Integer = 0 To pram.Length - 1

cmd.CommandType = CommandType.Text

help me in this to solve this, need result based on this two query


This is my query im little struct need help

SELECT  a.ItemName
	  , a.AvailableQty   
	  -- - ISNULL(b.RequiredQty,0)  AS Balance Total

  FROM ( SELECT l.ItemName,
               l.Weight * 30 /100 as AvailableQty
           FROM dbo.FR l inner join dbo.Fg m
on l.ID=m.ID 
m.A='C' and m.S='B') AS a
  ;with cte as 
(select Date,A,S,Types,Refno,Sum(P.Consumption) over (partition by RefForAll) - ISNULL( t.Qty,0) as Qty,ROW_NUMBER() 
over (PARTITION by RefForAll order by ID desc) as rn from dbo.MReg P 
cross apply (select SUM(Qty) as Qty from dbo.FDes where RefForAll = P.RefForAll)t 
where RefForAll in (select RefForAll from dbo.MReg)) 

(select ll.ItemName,
               ll.Weight * Z.Qty /100 as RequiredQty from cte as Z               
               inner join  dbo.Fg m on Z.A=m.A and Z.S=m.
               inner join dbo.FR ll on ll.ID=m.ID 
               where Z.rn = 1 and Z.Qty!=0 
               and m.A='C' and m.S='B') 

The first query above left outer join its work fine... second query after left outer join i cant able to do..

What i need is i need to set this


Selecting Result from Content Query Wb Part gets Webpage cannot be found Error

I have MOSS 2007 running on Windows Server 2008.

I have added a custom List to a MOSS 2007 site sollection. The List works fine.

I have added a new webpage to the site collection Home page that includes a Content Query Web Part. When the Content Query WP is configured it returns items from the custom List as expected. But when I select one of the result items returned by the Content Query WP, the Browser says "The webpage cannot be found."

Why doesn't the Content Query WP result navigate to a page that displays the List item selected from the results list?

I have 2 items returned in the CQWP results list and both generate the same error when selected.

If I go to the custom List, the items display OK when selected.

The URLs generating the error looks like:

Content Query result without link to source list

I've added a content query webpart to a page to show a multiple line text field from a list item. That works fine but the content is shown as hyperlink and if I click the content, the source item of the list is shown. I wanted to use the content query only to show the filtered content, without having the possibility to open the related item. Is that possible or is the content query webpart the wrong way to show content from different sources (lists) only as text in a page?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend