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


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

how to write this query?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :
 

i have this data (in a column as nvarchar(max))

<S> <B> <x>zzz</x>

I want to get/show zzz

i tried this but not work:

 declare @x XML

select @x = q from [qq]
where key = '999'

select @x.value('(/S/B/x)[1]', 'varchar(50)')




View Complete Post


More Related Resource Links

How to write the LINQ query for the following

  
Hello All, I have an entity type with the following properties: UnitId, UnitDescription, ParentId, EffectiveDate - (Say the entitty type is Unit)  I want to filter out a list of UnitIds whose effective date is less than a given date. But since there could be many EffectiveDate s less than a given date, I want to take the latest one(Max). Simply told, I want to get the unit ids with the most recent effective date prior to a given date. How can I do this in a single linq statement? Appriciate any help.

How to write query with subquery more efficient

  
Hello, I have this query which generates sick days. I have a sick start date and end date, and by joining it with a date table I get all sick days for each employee. But as you can see i select a number of fields, but in the subquery i select a number of fields which are the same. Is it possible to write it more efficient? Thans in advance! SELECT z .ziekmeldingID, z .hrmID, z .ZiekStartDatum, z .ZiekEindDatum, z .ZiekStartTijd, z .ZiekEindTijd, z .ZiekOpen, z .ZiekTypeID, z .ZiekRedenID, z .ZiekStart_KEY, z .ZiekEind_KEY, z .Verzuimduur, D .Datum AS ZiekDag,   CAST(CONVERT(char(8), D.Datum, 112) AS int) AS ZiekDag_KEY, z .hr301_date, z .PercentageZiek, z .PercentageHersteld FROM     (   SELECT dbo .hr300.hr300_obj AS ziekmeldingID, dbo .hr300.hr300_date_start AS ZiekStartDatum,   CASE   WHEN dbo.hr300.hr300_date_end IS NOT NULL   THEN dbo.hr300.hr300_date_end   ELSE getdate()   END AS ZiekEindDatum, dbo .hr300.hr300_time_start AS ZiekStartTijd, dbo .hr300.hr300_time_end AS ZiekEindTijd, dbo .hr300.hr300_open AS ZiekOpen, dbo .hr300.hr104_obj AS ZiekTypeID, dbo .hr300.hr038_obj AS ZiekRedenID, dbo .hr300.hr200_obj AS hrmID,   CAST(CONVERT(char(8), dbo.hr300.hr300_date_start, 112) AS int) AS ZiekStart_KEY,   CAST(CONVERT(char(8), dbo.hr300.hr300_da

Write select query with a paremetrized where clause, and populate database with the retrieved column

  
I want to be able to retrieve column values using the dropdownlist values as parameters then populate the tbPO table with the retreived values. Where and how do I do it. ImportsSystem.Data.OleDb ImportsSystem ImportsSystem.IO Imports ?directcostDataSetTableAdapters PartialClass po_header  Inherits System.Web.UI.Page  Dim cn As OleDbConnection  Dim cmd As OleDbCommand  Dim dr As OleDbDataReader  Dim icount As Integer  Dim str As String  Dim vendor_id As Object   ?  Public Sub btn_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.ClickTry   context.Items.Add(     cmd.CommandType = System.Data.   cmd.CommandText = Dim context As HttpContext = HttpContext.Current"Company_Name", DropDownList3.Text)Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\Owner\Documents\Visual Studio 2010\WebSites\WebSiteJun25\App_Data\directcost.mdb;")Dim cmd As New OleDbCommand()CommandType.Text"insert into tbPO(ponumber, suppliername, ShipTo, basictype, DateNeeded, Purpose,ShippingInstr, ProjId) values(?,?,?,?,?,?,?,?)" cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.Add

Query help to write case statement in Where clause?

  
Hi All, I have table something like this:- SELECT UserName, IsManager FROM Employee IsManager has only two values either 1 (which means user is a Manager) or 0 (which means user is not a Manager) Now I want to write below query:- DECLARE @IsManager INT SET @IsManager = 2 SELECT UserName, IsManager FROM Employee WHERE IsManager = CASE WHEN @IsManager = 1 THEN 1 WHEN @IsManager = 0 THEN 0 WHEN @IsManager = 2 THEN 1 | 0 ----- THIS IS NOT WORKING, when I set @IsManager value to 2 then where clause should be like this "IsManager = 1 OR IsManager = 0" END Can anybody help me out in modifying about query so that it produces both the results when @IsManager variable value "2". Thanks Regards, Kumar

How to extend this query to write the results back to a database?

  
FOr this query I have four tables I would like to access. SELECT StockA, SUM(Score) AS Total FROM dbo.ScoresNew_LongPrice WHERE [When] >= @StartTime AND [When] < @EndTime GROUP BY StockA ORDER BY SUM(Score) DESC _LongPrice, _ShortPrice, _LongVolume, _ShortVolume I would like to improve the above query to return not just the results from LongPrice, but four columns, of sum(score), from each table, if possible. And, if that is possible, I would also like to have the query then update another table with its results.  Not a new table, but just updated to an existing table. Anyway, I can do some stuff in T-SQL but this seems over my head.  Any help would be appreciated. (The four tables all have identical structures)

is there any tool or add-on for write color and comfortable query on access-2007 ?

  
hi is there any tool or add-on for write color and comfortable query on access-2007 ? thank's in advance

Help to write very simple query...

  

How I can write this query ?

I have value = 1000

I wont to get all value from table [MHGROUP].CUSTOM2

from column CPARENT_ALIAS

all values which beginning with num 1000.

SqlCommand

 

cmd2 = new SqlCommand("SELECT * FROM [MHGROUP].CUSTOM2 WHERE CPARENT_ALIAS ='" + value + "'", con2


How to write the correctly query to this task?

  

Hi All.

I have sql table with three columns Cparent_alias ,Custom_alias,C_descript I wont to update the name in C_descript column BUT before I need to check if the name already exist or not.

Cparent_alias

Custom_alias

C_descript

How to write SQL Insert into query using LINQ

  

How I can write following SQL query using LINQ. There is no default constraint define for the ID column so we have explicitly pass the NEWID().

I want to replicate the products of a company to another company.

Insert Into Products
Select NEWID() AS ProductID, ProductName, CompanyID = @DestinationID, ProductCategoryID From Products Where CompanyID = @SourceID

Also once I get these result how can I use InsertAllOnSubmit to insert all the records at once without looping it.


How do I write this kind of Linq query?

  

Hi,

I have this kind of class:

class A{
  public int a;
  public int b=0;
  public(){}  
}

and I have this list: List<A> l;

for example. data in this l is: {a=1,b=0},{a=2,b=0},{a=3,b=0},{a=1,b=0},{a=3,b=0}

Now I would like to find out every A in l, that if there are more than two A that have same value of a, then their b should all be set to 1.

In this case, the list of l should finally like: {a=1,b=1},{a=2,b=0},{a=3,b=1},{a=1,b=1},{a=3,b=1}

because there are two A have value 1 of a, and two A have value 3 of a, only the second A in the list has unique value 2 of a.


Please teach me how to write this kind of linq query.

Thanks!


Problem to write a query..using COUNT()...

  

I am facing problem to get desired output..

i m using query as written below.........


SELECT  studentprofile.RollNo, AttendanceMaster.ScholarID, studentprofile.StudentName 

COUNT(AttendanceMaster.AttendanceStatus) AS Expr1

FROM         AttendanceMaster AS AttendanceMaster INNER JOIN
                  studentprofile AS studentprofile ON                    AttendanceMaster.ScholarID=studentprofile.ScholarID

WHERE 

(studentprofile.Section = 'A')

AND (studentprofile.Class = 'Nursery')

AND (studentprofile.SchoolCategory = 'PRE SCHOOL')

AND (studentprofile.SchoolType = 'XYZ School')

AND (AttendanceMaster.AttendanceStatus = 'Present')

AND (AttendanceMaster.Date BETWEEN '11/1/2010 12:00:00 AM' AND '11/30/2010 12:00:00 AM')
GROUP BY studentprofile.RollNo,AttendanceMaster.ScholarID, studentprofile.StudentName


this query gives output propery for those students who comes(AttendanceStatus='Present') atleast ne day........but unable to show the the re

How to write the following query in oracle..?

  
hhh

SELECT

 

 

 

 

DISTINCT d.AGREEMENTID

 

 

,d.AGREEMENTNO

 

 

How to write the following query in oracle..?

  
hhh

SELECT

 

DISTINCT d.AGREEMENTID

 

,d.AGREEMENTNO

 

,A.CHEQUEAMT

 

How to write the following query in oracle..?

  
 

Hi all

Can anybody let me know how to write the same query below in oracle...?

SELECT

 

 

 

 

DATEADD(MONTH, DATEDIFF(

How to write the following query in oracle..?

  
 

Hi all

Can anybody let me know how to write the same query below in oracle...?

SELECT

 

 

 

 

DATEADD(MONTH, DATEDIFF(

How to write the following query in oracle..?

  
 

Hi all

Can anybody let me know how to write the same query below in oracle...?

SELECT

 

 

 

 

 

 

 

 

DATEADD(MONTH

How to write the following query in oracle..?

  
 

Hi all

Can anybody let me know how to write the same query below in oracle...?

SELECT

 

 

 

 

DATEADD(MONTH, DATEDIFF(

Categories: 
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