.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

Data retrive using xml type column

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


I am using following table to store user details.

CREATE TABLE [dbo].[TRN_User](
	[UserID] [bigint] IDENTITY(1,1) NOT NULL,
	[AccountNo] [int] NULL,
	[Title] [varchar](50) NULL,
	[FirstName] [varchar](100) NULL,
	[LastName] [varchar](100) NULL,
	[UserAttributes] [xml] NULL
	[UserID] ASC

UserAttributes is a xml type column and the data in that column is depend on the UserType. Following is a sample xml of a record.


View Complete Post

More Related Resource Links

Is there any way to populate an InfoPath form field with the data from the site content type column?


I have a Form library with a form template.

The templat has a field "Office name" which should not be a fixed list of values, but a dynamical list, feeded from a different type of form. I'm a novice with InfoPath - Sharepoint and I want to find out, how can I can give users a possibility to create and maintain a list of offices and also have this list as a selection list inside main library form - ALL inside one library, if possible.

I assumed that if I publish main form (Itinerary) as a library template form and lookup form (OfficeInfo) as a SiteContent, I should be able somehow to connect to siteContent column and it's information. But I cannot see how - Site Content Gallery is not appering as a Connection item.

Can I use SiteConenct for this purpose or there are other ways to create end-user lookup lists?

Thank you!


Complex Matrix column data with different data type

I have a data like this

drop table #table
select 34 as A,17948 as B,0.19 as C,19 as D,16145 as E,'Jan' as Period into #table
Insert into #table
select 26 as A,14206 as B,0.18 as C,19 as D,13411 as E,'Feb' as Period
union all
select 38 as A,13037 as B,0.21 as C,18 as D,14974 as E,'Mar' as Period
select * from #table

From this #table i want the view as below format and is doable thru matrix report option in SSRS,but the problem i am running is that i cannot get in this type of data type format. If you look into it,i have column with header 'Jan' and it has data in different data type e.g money,number,percentage. I need to maintain this data type in order to do the calculation after it generates the report on excel spreadsheet. If i use the varchar for the column, it is not usable to me in the final report and i cannot do the calcualtion. Any workaround will be highly appreciated.

    Jan               Feb          Mar
A $34               $26          $26
B 17,

DataGridView object column 'data type' assignment

How do I assign a 'data type' to an 'unbounded' datagridview object

column - data type


Hi All,

My data is:

What data type should I use and how many posts should be?
This time use data type = numeric (18.4)
This is not good.
Do I need to be increased to (18.8)?

Please Help

Syntax error converting varchar value to a column od data type int


Hi everyone,

I'm having a problem where I've created a stored procedure with a dynamic ORDER BY clause and it's returning a syntax error:

Server: Msg 245, Level 16, State 1, Procedure usp_OrderBy, Line 4

Syntax error converting the varchar value 'Closed' to a column of data type int.

Here is the code that I'm trying to execute. It works fine if I take out the ID line:

CREATE PROCEDURE [Task_User].[usp_OrderBy]
  @orderBy varchar(100)
  SELECT ID, Status, PostedBy, Assigned, Subject
  FROM mainTable
    WHEN @orderBy = 'ID' THEN ID --When I take this out, it works
    WHEN @orderBy = 'Status' THEN Status
    WHEN @orderBy = 'PostedBy' THEN PostedBy
    WHEN @orderBy = 'Assigned' THEN Assigned
    WHEN @orderBy = 'Subject' THEN Subject
Any ideas as to what I can do to fix it?

Changing column Data Type when using merge replication: RFC on my SMO code.


I maintain an application for that uses SQL 2005 / 2008 for data persistence.
Some clients use Merge Replication (pull or push) to replicate data.

Some of the data the application stores should be "versioned". All versions of a row containing medical information should be stored, somewhere in a database. This means all updates and deletes to those rows should result in in 2 affected rows:

  • a copy of the row before the change
  • a row containing the change (or the deletion of the row in question)

I plan to achieve this using triggers on all the tables for wich "versioning" is required.
The old versions of a row may be stored in the same database, an other database (or a database on a linked server).

Unfortunalty, the AFTER UPDATE, DELETE triggers do not support TEXT, NTEXt an IMAGE data type columns.
Thus I am required to convert all text, ntext and image columns to their respective "new" data types, varchar(max), nvarchar(max) and varbinary(max).

This is not a big issue when the database is not published, but when it is... most articles (and posts) i've read suggest:

  1. Add a column of the target data type to the table, copy data from source column. rename columns and drop the source column.

  2. Create a temp table (with the s

Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

Rendering data with HTML tags in the DD Gridview for a selected column


I am having trouble finding out where and how to HTML Encode a cell's data on the Dynamic Data (v4.0) gridview of List.aspx.  As a simple case, suppose I have formatted cell data that is A<br/>B in the DB.    Obviously, I want A stacked on B in the cell.

It seems gridView1.HtmlEncode = true has gone away.

So maybe I'll try to catch it on the RowDataBound event:

protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)

            if (e.Row.RowType == DataControlRowType.DataRow)
                // Html Encode the cells


but this event never fires?

Has anyone figured out how to properly render HTML tags data in the List.aspx's GridView1? 

If I figure this out, then I can add a MetaAttribute called something like [EncodeAsHtml(true)] and be on my way.  Thanks!

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must



This is frustrating, and I don't know how to solve it.

I have a strange problem. I am adding a LinqDatasource object, and set the context:

        protected void LinqDataSource_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
            e.ObjectInstance = new KaruselaDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

Then I get this error:
The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


On web.config I already have this:
<add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?


Data Points: Column Expressions, DataRelations, and Computations


This month John Papa fields some of his favorite questions regarding data manipulation with ADO.NET.

John Papa

MSDN Magazine January 2007

XML in Yukon: New Version Showcases Native XML Type and Advanced Data Handling


The next version of Microsoft SQL Server, code-named "Yukon," represents quite a few steps forward in the evolution of XML integration. Yukon supports native storage of XML data using the XML data type, which makes it possible to run native queries on XML data using the emerging industry standard XQuery language. Data integrity of the XML data type can be enforced through schema validation and XML-based check constraints, and special indexes can be defined that help speed up queries. In addition, Yukon has the built-in ability to expose its data through Web services. This article discusses these and other XML features of Yukon.

Bob Beauchemin

MSDN Magazine February 2004

split one data column into many?


Hi, I've a database table contains survey questions and answers. But the problem is both 'question' and 'answer' are saved in the same column(like below).

SubmissionDate                                                          Submission

2010-02-15 14:53:59.657                     ***What's your pet's name?***  Lili ***Tell us about yourself*** I'm a teacher

2010-02-15 14:53:59.657                     ***What's your pet's name?***  Lucy ***Tell us about yourself*** I'm a five star cook

I'd like to use a simple datagrid to display the survey result, but I need to separate the submission column into multiple columns ('question' as column name, 'answer' as data)

the number of questions or questions being asked are different for each survey so they are not fixed. 

Is it even possible to get something like this below in a gridview? 


override error message (The value 'test' is not valid for Age) when input incorrect data type for in


Hello everyone,

I've tried to override error message when input incorrect data type in input field on HTML form. For example I have the model like this.

public class Person
public string FirstName {get;set;}
public int Age {get;set;}


For view, I put text input for Age to get it value.

When type some string in Age text box like 'test' and press submit button. I got this error message

The value 'xxx' is not valid for Age

However, I want to change this message and try many way. There 's nothing effect this message value.

Please could you help me to solve this problem.

Error converting data type varchar to numeric.


I create a form to record data using ASP.NET and SQL database...
when i run the project show error "Error converting data type varchar to numeric"

what's the problem actually.i try to change in datatype in database..
but still showing error...


WSS 3.0 Content Type - Lost data for Titles


We are running WSS 3.0 SP2 on server 2003.  Recently, we lost the "Titles" for all content types for documents.  Our system Content Type for Document is set up to require this field to be completed on all documents that is uploaded.  Our system would automatically enter in by default the name of the document in the "Title" field it no longer does this for the user.  The user must now enter in manually the "Title".  How do I get it to enter in the "Title" using the document file name automatically?

Below is the way the setting page for Site Content Type: Document looks like.  (I tried to recreate it since I could place a screen shot in the box)

Site Content Type Information
Name:  Document
Descriptiong:  Create a new document.
Parent:  Item
Group:   Document Content Types

Name, Description, and group
Advanced settings
Workflow settings
Delete this site content type

Name                 Type                     &nb

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