.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

How to use 'Like' operator in XQuery?

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :Sql Server
Hi All, I've a huge XML. Following is the layout: <Root>           <Request ID="12160884">                    <Command ID="1" Item="Start_Loading" Error="" />                    <Command ID="2" Item="GetData()" Error="Unknown group 'Data'" />                    <Command ID="3" Item="End_Loading" Error="" />           </Request>           <Request ID="12161224">                    <Command ID="1" Item="Start_Loading" Error="" />                    <Command ID="2" Item="GetCompanyInfo()" Error="" />               &

View Complete Post

More Related Resource Links

Data Points: Using XQuery, New Large DataTypes, and More


SQL Server 2005 introduces a lot of new features, but it also enhances the popular and oft-used Transact-SQL (T-SQL) language. Changes include the introduction of new datatypes to store large values using the MAX indicator, the integration of enhanced XML querying and data modification with XQuery, and the new XML datatype.

John Papa

MSDN Magazine March 2006

Advanced Basics: Revisiting Operator Overloading


On the conference circuit recently, I was speaking about some of my favorite new features in the Microsoft® . NET Framework 2. 0, using the content of three recent columns in this series as fodder. In my talk I sped through generics, operator overloading, and the BackgroundWorker component, all in the space of an hour (for the columns, see Advanced Basics: Being Generic Ain't So Bad, Advanced Basics: Calling All Operators, and Advanced Basics: Doing Async the Easy Way).

Ken Getz

MSDN Magazine September 2005

Syntax error (missing operator) in query expression

Good Day Gurus!

I have a Excel user application which has a user form (named 'Registo') that displays criteria and an image that has been entered in it's corresponding spreadsheet. This works the way it should.  There's also the ability to search the spreadsheet via a form (by clicking 'Pesquisar' button) this opens a search form. However, I having a bit of a problem with it. When I try to search for something it basically doesn't do anything at all. It just sits there. So I tried to debug it and I think I'm having a problem with either the JET db engine or somethign with teh query or maybe I don't have the correct reference.

I 'borrowed' this Excel application from another forum because it's exactly what I'm looking for! However, I suck at vb.

So I was hoping somebody could take a look at the code and see if I'm missing something?  I'm kinda' desparate to get this working because I'm been trying to figure it out for days and I'm running out of time.  Cry
Option Explicit

'constantes para auxiliar na verificação do código
Private Const Ascendente As Byte = 0

GridView Paging + Unsupported overload used for query operator 'Distinct'


The issue is two fold in my ASP.NET Web Application. I need to use a custom Distinct() via LINQ to SQL, and then assign thevar as a DataSource to a GridView. If I use the custom Distinct that implements IEqualityComparer, I get "Unsupported overload used for query operator 'Distinct'" exception. but if i somehow get past this, i get "The data source does not support server-side data paging" exception on GridView.DataBind(). here is the code:

distinct_employees =
    (from emp in wsq.LIT_Active_Employees
    where (String.IsNullOrEmpty(ssFirstName.Text) ? (emp.FIRST_NAME == null || emp.FIRST_NAME.StartsWith(String.Empty)) : emp.FIRST_NAME.Contains(ssFirstName.Text)) &&
            (String.IsNullOrEmpty(ssLastName.Text) ? (emp.LAST_NAME == null || emp.LAST_NAME.StartsWith(String.Empty)) : emp.LAST_NAME.Contains(ssLastName.Text)) &&a

Using the "IN" Operator with SelectCommand Parameter


Good morning everyone,

Any ideas how I can use an "IN" operator with a SelectCommand Parameter.



Where @DEPTS is a value stored in a Cookie.  Cookie("DEPTS").Value is "232,243,250"

I keep getting an nvarchar to smallint conversion error.  Has anyone ever tried to do this?

Mod (%) operator on x86 vs x64

Hi all , I need help for resolve a strange bug – when I use mod (%) operator on x86 all good , But on x64 I get sometimes NaN as remainder ( it usually happens with Angle = 0). I managed to reproduce that bug outside my code , but only with Angle = double.Epsilon (at my code it also happens with Angle = 0). class Program { public const double M_PI = 3.14159265358979323846; static void Main(string[] args) { double m_2PI = (2 * M_PI); double m_Angle = double.Epsilon; double mod = (m_Angle % m_2PI); //x86 mod = 4.94065645841247E-324 //x64 mod = NaN if (double.IsNaN(mod)) Debug.Write(mod); } } Regards , Shay

How to use a dynamic XPath with XQuery?

HI, I've a problem with dynamic XPath-Expressions used in Xquery functions as shown below.DECLARE @XML1 xml DECLARE @XPath as varchar(200) SET @XML1='<Root> <Device> <Inspection> <Status>OK</Status> </Inspection> </Device> </Root>' -- This returns the correct results SELECT @XML1.query('/Root[1]/Device[1]/Inspection[1]/Status[1]') SELECT @XML1.value('/Root[1]/Device[1]/Inspection[1]/Status[1]','varchar(5)') -- This returns the Xpath-Expression itself or a part of it and not the expected results SET @XPath='/Root[1]/Device[1]/Inspection[1]/Status[1]' SELECT @XML1.query('sql:variable("@XPath")') SELECT @XML1.value('sql:variable("@XPath")','varchar(5)')What's wrong with the use of "sql:variable"Thanks in AdvanceRaimund

XQUERY using Cross Apply and Outer Apply

Trying to shred XML into relational table rows and can do it for one set of node values .. having difficulty creating a pair of columns. The relevant part of the XML looks like this ... <ns:Coverage>      <ns:CoverageCd>cvalue1</ns:CoverageCd>      <ns:Form>           <ns:FormNumber>fvalue1</ns:FormNumber>      </ns:Form> </ns:Coverage> I can successfully navigate through the XML and pull back a set of rows for all values of CoverageCd. Now I'm trying to add a column to each output row for the FormNumber value associated with the CoverageCd value. However; FormNumber is not always present. I found an example where using 'Outer Apply' can account for that, but it's not working for me. Here's my XQuery: WITH XMLNAMESPACES('http://www.mycompanyname.com/ACORD1.11.0/Policy_1.0/xml' AS "ns") select cov.i.value('.', 'varchar(30)')   [Coverage],          form.i.value('.', 'varchar(30)')  [FormNumber] from  dbo.mytablename        cross apply XMLcolumn.nodes('.//ns:Coverage/ns:CoverageCd') as cov(i)        outer apply cov.i.nodes('.//ns:Coverage/ns:Form/ns:FormNumber) as form(

XQuery: Unable to resolve sql:variable('@variable').

Solution to problem in SQL 2005: http://beyondrelational.com/forums/p/4289/7997.aspx USE tempdb GO -- If table exists, drop it IF OBJECT_ID('Tbl','U') IS NOT NULL BEGIN DROP TABLE tbl END GO -- Create the source table CREATE TABLE Tbl (col XML) INSERT INTO Tbl (col) SELECT ' <page height="782" width="620" id="page1" number="5"> <layout> <region id="r1" x="0" y="0" height="782" width="620"> <img src="../../Images/page11.swf" /> </region> </layout> </page>' -- Local variables DECLARE @page1 VARCHAR(20), @sQuery NVARCHAR(MAX), @insertXML NVARCHAR(MAX) SET @page1 = 'page1' SET @insertXML =' <hotspot id="C0D7AE7C5807FCA934C02E8FE1765031E4B4FC3B" x1="38.45" width="0" y1="53.6" height="0" FileName="" pageRF="" roleId="1" FilePath="" externalLinkURL="http://...._hsw_hswsnake.pdf" title="A visual ...Works." index=""> <role id="34" action=""/> </hotspot>' DECLARE @sql NVARCHAR(MAX) SET @sql = 'UPDATE Tbl SET col.modify('' insert ' + @insertXML + ' into (//page[@id=sql:variable("@page1"

//Operator '+' cannot be applied to operands of type 'L' and 'L'

  public L Mymethod<L>(L mydate, L myname) {   //it is getting following errro   //Operator '+' cannot be applied to operands of type 'L' and 'L'   return (myname+myname); }   Can any one give me help how to solve following error

Using Xquery with XML and vb.net to create a search facility

Hi Guys Newbie usign vb.net and vs2005, with .net.2.0 Need some help, i have a page with a datagrid, it is using an xml file as the datasource, it has paging and this works fine, what i now want to do is query the xml file based on the data the user enters into a text box, i then want to run the query using xquery and return the result set to a label. I have the code below so far which is searching my xml file using a fixed hard coded search parameter and it works but im stuck on how to implement the textbox text and search. <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:Label ID="Label1" runat="server" Visible="False"></asp:Label><br /> <br /> <asp:TextBox ID="searchtxt" runat="server"></asp:TextBox>&nbsp;<asp:Button ID="search" runat="server" Text="Search" /><br /> <br /> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="15"> </a

XQuery in TSQL

Why can i use it like this:   SET @xml.modify(' delete if(/employees/employee/name[sql:variable("@index")][contains(.,@type)]) then (/employees/employee/name[sql:variable("@index")]/@type) else() ')   but can not use it like this:   SET @xml.modify(' insert attribute type {string("Normal")} as first into (/employees/employee/name)[sql:variable("@index")] ')  

Using equal operator in transact-SQL for ntext datatype column

Hi, I've a problem with using equal operator in transact-SQL for ntext datatype column. (SQL Server 2000) I'm using the following SQL command text. use NorthwindSelect * from Categorieswhere Description ='Seaweed and fish' If I use 'like' operator intead of '=' then the qurey retuns correct value. Any idea about this? Any help is appreciated. Regards, Julia

The data types varchar and date are incompatible in the add operator

On the following query I keep getting the error 'The data types varchar and date are incompatible in the add operator'.  As you can see I have tried to convert the date but doesn't seem to work.  The variable @Date1 will start off as a date.  Any suggestions? ' declare @Date1 date declare @SQL1 varchar(2000) set @Date1 = convert(varchar, cast(getdate() as date), 102) set @SQL1 = 'select * from tbl_1 where convert(varchar,cast(tbl_1.Current_dt as date),102) = '+@Date1+'' print @SQL1    LISA86

WebSecurity.Login Operator '==' erro?

Server Error in '/' Application. Operator '==' cannot be applied to operands of type 'string' and 'int' Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Operator '==' cannot be applied to operands of type 'string' and 'int' Source Error: Line 12: login_password = Request.Form["login_password"]; Line 13: var login_username = Request.Form["login_username"]; Line 14: if(WebSecurity.Login(login_username, login_password)){ Line 15: Response.Redirect("~/"); Line 16: } Source File: c:\login.cshtml Line: 14 Stack Trace: [RuntimeBinderException: Operator '==' cannot be applied to operands of type 'string' and 'int'] CallSite.Target(Closure , CallSite , Object , Int32 ) +155 System.Dynamic.UpdateDelegates.UpdateAndExecute2(CallSite site, T0 arg0, T1 arg1) +258 CallSite.Target(Closure , CallSite , Object , Int32 ) +167 Microsoft.WebPages.SimpleMembershipProvider.VerifyUserNameHasConfirmedAccount(Database db, String username, Boolean throwException) +798 Microsoft.WebPages.SimpleMembershipProvid

Not Equal To Operator (<>) Behavior

Can someone explain this behavior with the <> operator when used along with a variable as opposed to a hard coded value. I'm totally confused (: Thanks for the help! -- Scenario 1: Value 3 is hard coded if object_id ('tempdb..#t') is not null drop table #t GO SET ANSI_NULLS OFF GO create table #t (c1 int null) insert into #t select 3 insert into #t select NULL SELECT * FROM #t WHERE c1 <> 3 -- 0 rows returned ---------------------------------------------------------------- ---------------------------------------------------------------- -- Scenario 2: Value 3 assigned to variable @a and used if object_id ('tempdb..#t') is not null drop table #t GO SET ANSI_NULLS OFF GO create table #t (c1 int null) insert into #t select 3 insert into #t select NULL declare @a int = 3 SELECT * FROM #t WHERE c1 <> @a -- 1 row returned with NULL value.. Why..?? ---------------------------------------------------------------- ---------------------------------------------------------------- -- NOTE: Both the queries ve the ANSI_NULLS OFF  
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