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

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

Query an XML field

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

This seems like a simple thing to do, but I can't figure out how...

I have an XML field in my table called Rules.  The data looks like this:




<LookupSet BusinessColumnName="Produce" Grocer="ABC">

  <Lookup LookupID="5" OutputValue="Fruit">





  <Lookup LookupID="6" OutputValue="Fruit">





  <Lookup LookupID="7" OutputValue="Fruit">





  <Lookup LookupID="8" OutputValue="Vegetable">







View Complete Post

More Related Resource Links

Dynamic query for Null field checking

Hi I want dynamiclly find the table to null values finding.. Please give me quickly   Regards Ram

Dynamic query for datalength field checking

Hi   Please tell me the dynamic query length in table

Dynamic query for Null field checking

Hi I want dynamically check the data Formation query in SQL server please  provide me the query

using a database field as a hyperlink query?

I have three tables in my sql database contactssurvey answersrespondent_initialContacts holds all customer data with custid. survey answers has assigned everyone how took the survey a number in a field called respondent_no.respondent_initial holds input from a webform where I populated it with the custid from contacts and respondent_no from survey answers before the webform input is inserted. I want to send an email to them that had there respondent_no in a hyperlink to the webform so that when they entered their data into the webform it would use the repondent_no to determine where to insert the form data.Example joe clicks http://www.myplace.com/order.aspx?23             Mike clicks http://www.myplace.com/order.aspx?125it would look up respondent_no (23) from the respondent_initial table and insert the data in that row in the database for joe's webform entry and it would look up respondent_no (125) from the respondent_initial table and insert the data in that row in the database for mike's webform entry.my code behind looks like this// Create command                comm = new SqlCommand("INSERT INTO respondent_inital (Practice_Name, Address1, Address2, City, State, Zipcode, Phone, Email, Contact, Dealer, item_9223, item_9129, item

Field method missing with LINQ query

H, I want to access the data from datatable object. When i trying to get the fieldslist usng "Field" method. But I could not find the method with my table object.  Eventhoguh i forcibly write a method and trying to access the fields, It is giving the below error for the first join in query. Rest of the lines are fine. What is the reason behind it. The errro: "Error 2 'LINQ2DB.SP_VS_OP' does not contain a definition for 'Field' and the best extension method overload 'System.Data.DataRowExtensions.Field<T>(System.Data.DataRow, string)' has some invalid arguments" What is the meaningof the error. Shall i do any other changes in the query line?                         var QueryChnl = from oSPOP in SPOP.AsEnumerable()                        join oDiscChannel in DiscChannel.AsEnumerable() on oSPOP.Field<int>("spid") equals oDiscChannel.Field<int>("SPID")                        join oChannel in Channel.AsEnumerable() on oDiscChannel.Field<in

parameterized query and Date Field

Hi!Using this SQL:SELECT fac_op_d.cod_art_i, SUM(fac_op_d.cantidad) AS total, inv_mp_m.nombre, fac_op_d.fec_doc FROM fac_op_d, inv_mp_m WHERE fac_op_d.cod_art_i = inv_mp_m.cod_art_i AND (fac_op_d.cod_art_i LIKE ? + '%') AND (inv_mp_m.almacen = 1) AND (fac_op_d.fec_doc BETWEEN ? AND ?) GROUP BY fac_op_d.cod_art_i, inv_mp_m.nombre, fac_op_d.fec_docThis is a query to an old FoxPro database on a server (Same Network). This work in the execution, but just passing the date values as aaaa/mm/dd.On my page when a pass two DateTime Parameters from two TextBox it throw "Unable to recognize the string as a valid DateTime Value"I'm using Ajax Calendar exterder on the textbox to be more specific.Here, (My Country)  the format i'm using es dd/mm/aaaaAnd when i select the datepicker it comes in this format, and then a get the DateTime error type.I can get the rows in the query builder just passing the date like "2010/01/15" and "2010/01/30" for example.Hay can i force the texbox to get this format aaaa/mm/dd?regards

Is there a way to use the value of a Field in a Query as another Field?


The situation is more complex than this, but this has the essence of it.

Two Tables:  History and Current

History has the fields:  lHistoryId, lCurrentId, FieldChanged, DateChanged, OldValue, NewValue,

Current has the fields:  lCurrentId, FieldA, FieldB, FieldC, FieldD

I woudl like to right a Query which shows all of the changes made during a certain period, as well as the current value for those fields.

The outpout would look something like:  (FieldC changed to "TestC3" after the period being queried for)

FieldChanged        OldValue        NewValue        CurrentValue

FieldB                   TestB1        TestB2        TestB2

FieldC                   TestC1        TestC2        TestC3


"SELECT FieldChanged, OldValue, NewValue FROM History WHERE (lCurrerntId = 123) AND (<...Date Range...>)" is the easy part, but how to get the CurrentValue?<

Content Query Webpart to show edit item link field in SPS2010


I have a Content Query Webpart in SharePoint 2010 that I would like to surface Documents grouped by content type. I wish to show the edit form or view Properties link as part of the fields shown in the results. When the User clicks on this link, it should take him to the edit form or view Properties page for the document.

Any ideas?

Lookup field which allows multiple choice - problem when query with CAML


I created one simple list and added one column - lookup - I've chosen some source list and field, then marked "Allow multiple choice". I created new item in that list, by adding more than one valie to that coulm.

The problem is, when I use CAML query, that column has such values:


and it's suppose to be like this:


do You have any idea, why it doesn't query first ID?

How to query a datetime field in access database using ASP.NET



I am using an Access database with one of the Table columns defined as Date/Time field.


I am trying to use ASP.NET 4.0 Web forms application to query and retrieve the row based on the DateTime field.

Here is my code snippet:

      string connectionString = WebConfigurationManager.ConnectionStrings["AccessDB"].ConnectionString;

      OleDbConnection oleDBConn = new OleDbConnection(connectionString);

      DateTime dt = new DateTime(dtBatchCreation.Year, dtBatchCreation.Month, dtBatchCreation.Day, dtBatchCreation.Hour, dtBatchCreation.Minute, dtBatchCreation.Second);

      //string sql = "SELECT [BatchID] FROM [Batch] WHERE [BatchCreationDate] = " + String.Format("{0:#yyyy-MM-dd hh:mm:ss tt#}", dt);
      string sql = "SELECT [BatchID] FROM [Batch] WHERE [BatchCreationDate] = @BatchDate";

      string s = @String.Format("{0:yyyy-MM-dd HH:mm:ss}", dt);

      OleDbCommand cmd = new OleDbCommand(sql, oleDBConn);

      //cmd.Parameters.AddWithValue("@BatchDate", s);


Nhibernate query ? specific field


how to pick a specific field (besides Primarykey field ) through HQL query ???

LINQ to SQL query to update based on coma separated field?


I have a field in my sql db with coma separated states, for example  "NY,CA,CT" I need to add a new record for each user that matches one of those states using LINQ to SQL.

Should I turn the field into a list and then loop thru the list? or is there a way to add them all at once?

If my tables is something like this:

UserID: 1
State: NY

UserID: 2
State: NJ

UserID: 3
State: CA

requestID: 1
States: "NY,CA,CT"

then my assigned table should be something like this

UserID: 1
requestID: 1
UserID: 3

User ID 2 is not added because NJ was not part of the request.

THank you

TSQL Query XML field with Namspace



I wish someone could point to me what am i missing in this query - I want to be able to collect the value in each of the node in the XML, but I got nothing return, even with  simple query

Here is what I have



@x xml

with xmlnamespaces (

'http://www.w3.org/2001/XMLSchema-instance' as xsi

CAML query on Lookup field returns no items



I have a problem with a very simple CAML query that works on WSS 3, but not on SharePoint 2010. The query is:

<Where><Eq><FieldRef Name='CUSTTABLE' LookupId='TRUE' /><Value Type='Lookup'>5624</Value></Eq></Where>

Where CUSTTABLE is the lookup field and 5624 is the ID of the item that the lookup value points to.

This works fine on WSS 3 but on 2010 it returns no results, I expect 5 results as I manually created 5 items that points to the item in the other list.

I'm not getting any errors, and queries on other non-lookup fields work as expected.

I have also tried changing the Type='Lookup' to Type='Integer' as someone suggested that might be the problem.

Has something changed in 2010? What is my next steps to figuring this out....



How to Query only Date Portion of Datetime field


Hi All

i have one data base field called CreatedDate whos Type is DateTime. Let say i have following Data in this Field

10/7/2010 12:07:57 PM

10/7/2010 12:09:14 PM

10/8/2010 01:02:34 AM

now if i pass date 10/7/2010 to my above table i'll not get any record. what is the best way to query only date portion of DateTime field

DataSet field missing while executing the query


Hi ... I have a dataset name distributorTotal in that there is a field name 'Current' which is Calculated field ... when i give ryt click on dataset -->query  then i executed query .. it is not showing any data and not showing field name as well..when i come out from that query designer ...field is missing under 'DistributorTotal' dataset..

now  there is no field under DistributorTotal...before i have 'current' field ...one more thing that 'Current' field doesnt have any data only null it had..that was null field actually

but i need that field to run the report.... getting tension...

please help me thank you...

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.
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