Tag: xml

SQL Server for xml returns custom xml format?

I have the following SQL with X(x) as (select ‘a’ union select ‘b’ ) , Y(y) as (select 1 union select 2 union select 3) select x, y from X cross join Y for xml path(”) and it returns <x>a</x> <y>1</y> <x>a</x> <y>2</y> <x>a</x> <y>3</y> <x>b</x> <y>1</y> <x>b</x> <y>2</y> <x>b</x> <y>3</y> Is it possible to […]

How to retrieve data from XML column in SQL

I have the following table layout: OrderDetails: ItemID (PK, int, not null) ItemName (nvarchar(450), null) OrderID (FK, int, not null) Discounts (nvarchar(max), null) The Discounts column is declared nvarchar(max) but the data is really XML – no idea why it wasn’t declared as XML. I need to query the table to show the OrderID, ItemName, […]

SQL Server 2005 Insert parent/child xml data

Given an xml document that looks like this here: <parentRecords> <parentRecord field1=”foo” field2=”bar”> <childRecord field1=”test” field2=”text” /> <childRecord field1=”test2″ field2=”text2″ /> </parentRecord> <parentRecord field1=”foo2″ field2=”bar2″> <childRecord field1=”test3″ field2=”text3″ /> <childRecord field1=”test4″ field2=”text4″ /> </parentRecord> </parentRecords> What would be the fastest way in SQL Server 2005 to pass this document into a stored procedure which would […]

Formatted .net web service (for .asmx solution)

I have searched this but really I couldn’t find the exact answer for .asmx solution. How can I create a .Net web service that is formatted as seen below? Also It will be connected with a database. <Books> <Book BookID=”1″ BookName=”BookName1″ Page=”100″/> <Book BookID=”2″ BookName=”BookName1″ Page=”200″/> <Book BookID=”3″ BookName=”BookName1″ Page=”300″/> </Books>

conversion of sql queries to xml format

Is there any tool or open source code to convert the sql queries [not the query results] to xml. Example : if i have a sql query like select * from employee where empname=’jon’. I want to generate this query in xml format like <root> <selectclause> <field table=”….> </selectclause> </root> Any plugins or open source […]

SQL Server FOR XML PATH vary tags dynamically

Trying to use FOR XML in SQL 2012. Need to have a result like this: <Loader xmlns:xsi=”url1″ xmlns=”url2″> <Buy_New> <Ticker>IBM</Ticker> <Acct>12345</Acct> <Qty>10</Qty> </Buy_New> <Sell_New> <Ticker>MSFT</Ticker> <Acct>12345</Acct> <Qty>15</Qty> </Sell_New> <Buy_New> <Ticker>IBM</Ticker> <Acct>12345</Acct> <Qty>10</Qty> </Buy_New> </Loader> After looking on here, MSDN, etc., I am not seeing a way to dynamically change the <Buy_New> and <Sell_New> (I have […]

How to show a column value which has XML file in webbrowser – C#?

I have table which stores entire XML file in a column. I want to show that column’s stored value (ie. XML ) in web-browser using C#. Please help/suggest some way to implement this. The trick is to retrieve the column and need to be displayed in webbrowser control. Please suggest. Thanks, Karthick

Concatenating rows from different tables into one field

In a project using a MSSQL 2005 Database we are required to log all data manipulating actions in a logging table. One field in that table is supposed to contain the row before it was changed. We have a lot of tables so I was trying to write a stored procedure that would gather up […]

Generate XSD from SQL Server database in order to import XML data

Is there a tool to generate an XSD schema from SQL Server database ? This XSD would be used for importing XML data into database with BULK INSERT or bcp

Issue updating XML column from .NET TableAdapter

I’m trying to update an XML column in a SQL Server 2005 table. Access to this column is through a stored procedure. I’m using a .NET tableAdapter to call this procedure. The problem: The value of the xml column does not get updated. Some observations: I used SqlProfiler to see if the stored procedure call […]

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