Tag: xml

How can I only retrieve rows with dates greater than today's date from an XML column in SQL Server?

I want to only return rows that have a date in the XML column after the current date in SQL Server. How can i do this? The error i receive for the last line below is: XQuery [LB_Webinar.WebinarXML.exist()]: There is no function ‘{http://www.w3.org/2004/07/xpath-functions}:GETDATE()’ ( @Site varchar(10) ) AS WITH XMLNAMESPACES (‘http://www.testsite.com/ClientWebinar’ as lbx) SELECT * […]

How can I convert a column value to a xml element name using SQL and FOR XML

I have the following table rows in MyTable: MessageID EMailAddress DisplayName RecipientType 1 joe@email.com Joe To 1, Bob@email.com Max From 1, Max@email.com NULL To 1, Secret@email.com Secret Bcc I am trying to convert this to XML that looks like the following: <to> <displayName>Joe</displayName> <address>joe@email.com</address> </to> <from> <displayName>Bob</displayName> <address>Bob@email.com</address> </from> <to> <address>Max@email.com</address> </to> <bcc> <displayName>Secret</displayName> <address>Secret@email.com</address> […]

Unrecognized configuration section connectionstrings. Trying to connect to SQL Server

I am trying to connect to a live SQL Server database as opposed to the local one for login authentication. Here are my settings in web.config: <connectionstrings> <add name=”scrumDbConnectionString” connectionstring=”Data Source=SERVERNAME;Initial Catalog=DATABASENAME; User ID=MYUSERNAME;Password=MYPASSWORD” providername=”System.Data.SqlClient” /> </connectionstrings> When I am in the website administration tool when I go to the security page I get the […]

SQL Server 2008 XQuery one to many issue

I have two tables in SQL Server with a one to many relationship. I need to perform a XQuery across these tables, to obtain an xml output The tables (and sample records) are those: Entity_A ID Name Description Value1 Value2 ———————————————— 10 aName1 aDescription1 AttVal1 AttVal2 11 aName2 aDescription2 AttVal21 AttVal25 Entity_B ID ID_Entity_A SubValue […]

would it be faster to parse XML from url or to save the informations in a database

I am relatively new to the development of a website with asp.net (C#) and SQL server 2008 (until now I was using php/mySQL). And I am currently facing some choices and any suggestion to help me make them would be really appreciated: I have a Database (let’s call it DB_A) wich is running under SQL […]

SQL – Read an XML node from a table field

I am using SQL Server 2008. I have a field called RequestParameters in one of my SQL table called Requests with XML data. An example would be: <RequestParameters xmlns=”http://schemas.datacontract.org/2004/07/My.Name.Space” xmlns:i=”http://www.w3.org/2001/XMLSchema-instance” xmlns:z=”http://schemas.microsoft.com/2003/10/Serialization/” z:Id=”1″> <Data z:Id=”2″ i:type=”CheckoutRequest”> <UserGuid>7ec38c44-5aa6-49e6-9fc7-25e9028f2148</UserGuid> <DefaultData i:nil=”true” /> </Data> </RequestParameters> I ultimately want to retrieve the value of UserGuid. For that, I am doing […]

Find all “null” values using xquery

I was tasked to find all values where <nodeA> is empty. That could mean that it is NULL, or that it doesn’t exist. I have crafted the below query SELECT * FROM table WHERE AttributeList.value (‘(/AttributeList/nodeA)[1]’, ‘varchar(50)’) IS NULL However it returns only results that look like <AttributeList /> What I am curious of is […]

Parsing XML from a select statement

I have a column in my table with XML that looks like this: <Notes> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>Test treatment notes 3</Contents> <DateCreated>2013-07-17T14:43:00</DateCreated> <DateModified>2013-07-17T14:43:00</DateModified> </Note> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>This is the intial notes test for tasks</Contents> <DateCreated>2013-07-17T14:36:00</DateCreated> <DateModified>2013-07-17T14:36:00</DateModified> </Note> <Notes> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>Test 4 of Task Notes</Contents> <DateCreated>2013-07-17T14:57:00</DateCreated> <DateModified>2013-07-17T14:57:00</DateModified> </Note> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>This is […]

Insert xml data into SQL server via SqlBulkCopy with powershell (casting error)

I’m getting a “cast not valid” error when trying to insert a data table containing xml using sqlbulckcopy. I cast the DataColumn that will hold the xml data to type System.Xml.XmlNode is that incorrect? Looking here it just says the .NET Framework type is xml. Here is an example of the xml I want to […]

insert Delta between to xmls to table- SQL

I have 2 xmls Like (the tags are Dynamic): Declare @OldXml xml = <Data><testId>BE7F2CDE-0D31-4E47-AA07-CE179F1E47C2</testId><description>Test1</description><Name>aaaa</Name><createdBy>1111</createdBy><updatedBy>1111</updatedBy></Data> Declare @NewXml xml = ‘<Data><testId>BE7F2CDE-0D31-4E47-AA07-CE179F1E47C2</testId><description>Test2</description><Name>bbbb</Name><createdBy>1111</createdBy><updatedBy>2222</updatedBy></Data>’ I want to enter the difference between them to another table like that: entity Field OldValue NewValue —————————————————————————————– BE7F2CDE-0D31-4E47-AA07-CE179F1E47C2 description Test1 Test2 BE7F2CDE-0D31-4E47-AA07-CE179F1E47C2 Name aaaa bbbb How can I do that? Hi ,After a long search,I’ve […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.