.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 do i sort varchar column with number

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :ASP.Net

i have a column in my table  of type varchar (50)







i want to sort in my sql querry like this







please help

View Complete Post

More Related Resource Links

how to sort a column varchar(50) that contains number


somebody please tell me how to write Sql querry to sort a column of type varchar (50) that contains number







instead of






How to show 0 as first number in column


Hi guys. I have two little problem.

I have database with one table and it has 4 rows.

1. I want to show a zero in front of all number. Actually i added but it doesn't show.

2. If i don't put any value in column is it possible to have minus for example instead of 0?




I post it like that because i can't see how to post pics directly.

P.S. The columns with numbers have checked "allow nulls".

I draw in paint so it's not so good but i think it's understandable.

10x in advance.

listView Sort for a celltmplate column

hi , i have a list view with a column that is binded to a field in my database the field contains integers that represents the City_ID , and i a have another table that contains the cities and their ID's, so , when i apply the sort based on this column (City Column) the list View is sorted based on the integers not on the city names here is my XAML definition of that column : GridViewColumn Header="City_Name_ID" Width="75">                         <GridViewColumn.CellTemplate>                             <DataTemplate>                                 <ComboBox IsSynchronizedWithCurrentItem="False" ItemsSource="{Binding Source={StaticResource CitysViewSource}}" SelectedValue="{Binding Path=City_Name_ID}" SelectedValuePath="City_ID" DisplayMemberPath="City_Name"/>                      &nb

What is the meaning of Ascending\descending sort order of a column within an index

When I add a new index I can also specify the "sort order" as ascending or descending. What does it mean? does it affect performance? does it mean that the binary search tree will be set in a certain way?

proper format for number column

Hi  In a column i have number datatype but after filling some no it's giving like that 23,786,23 (mostly like a currency format ) but i need like that 2378623 so give me suggestion how i can implement this in sharepoint 2010 , is there need to bound some column level validation for that ............... 

How to tell repeater to wrap text after certain number of characters for a particular column ?

I have a column in my repeater which allows as many as 255 characters and causes the page contents pushed away to the right if any of the record has all 255 characters in that column. How can I tell it to wrap the text after 50 characters ?Thanks,

Sort a WPF DataGrid on a Customized Column

I have several wpf DataGrids that use something similar to: {     Binding Path=ContactID, Converter={StaticResource contactIDToNameConverter}}"       As a best concept for various ID fields in my database.  This is great when needing to display editable data that is linked by ID, and my converter handles the validation and cleanup if needed. Otherwise an SQL View, or Joined Table SQL would not be able to send updates directly to the database (DataSet Wizard).  For this DataGrid's Contact column (bound to the ContactID field from a ICollectionView; bound to a DataSet.ClientsToContacts DataTable), I have an underlying value of Integer, and a converted surface value of String.  I want to sort on the string. Using ICollectionView.View.SortDescription(path,direction) will only sort on the Integer, and I am desprately seeking work arounds.  Please help. jvj

Wierd case of: Msg 213, Column name or number of supplied values does not match table definition

Hi, I'm working on several triggers (that happen after insert or update) in order to log the changes in a different table. They all follow a similar syntax and are working fine, except for this one... I've reduced the next code to the minimum that gives an error, so we can safely assume the other parts of the trigger are working fine. INSERT INTO [Adt].[WardUnitStayLog] SELECT t.* FROM [Adt].[WardUnitStay] t INNER JOIN inserted i ON i.[Id] = t.[Id]; I've used this same syntax (but on different tables) in other triggers, and these are working perfectly fine. The above query provides the next error: Column name or number of supplied values does not match table definition. I've checked both tables for differences in the columns, but to no avail... (I've checked them manually and by outerjoining the information_schema.columns) (I've also checked the order in wich these columns are defined, they match over the two tables) These are the creation scripts for the tables: CREATE TABLE [Adt].[WardUnitStay] ( [Id] [dbo].[Id] IDENTITY(1,1) NOT NULL, [UnifiedUnitStayId] [dbo].[Id] NOT NULL, [WardCd] [dbo].[Cd] NOT NULL, [_FirstAtTm] [dbo].[Dtm] NOT NULL, [_IsReservation] BIT NOT NULL, [_LastAtTm] [dbo].[Dtm] NOT NULL, [_LastBedCd] [dbo].[Cd] NULL, [_LastPhysicianUid]

How to know the number of columns displayed on the last page for Multi column table

Hi, How will I determine how many columns to be displayed on the last page of the report if I am using a Multiple column table.  I am going to use the number of columns to multiply with the width of the body of the report. I am going to use a Function to get the product. 

How to delete number in primary key column

Hi, BurnbetDataContext nwContext = new BurnbetDataContext(); var db = new BurnbetDataContext(); var personPets = from p in db.tbl_Payments where p.ID == 1 select p.ID; db.tbl_Payments.DeleteAllOnSubmit(personPets); This code does not work because the primary key ID.What should I do so I can delete the ID = 1?

Currency and number column error with office 2007 document formats in SharePoint 2010 library

Hi there,



The following error occurred within a SharePoint 2010 document library:

As I tried to test out the new SharePoint 2010 environment I changed the metadata from a few documents within a document library. I noticed that the data from the currency und number field was incorrect from a few documents. The numbers looked like that the decimal separator were ignored. For an example: 123.456,78 was saved as 12.345.678.

At first I thought it could be a language incompabilty but if that would be the case: Why would there be other documents which show the correct number?


I created another document library to recreate this error. And there I noticed the real reason: Every time I changed these fields from a document which was saved in the office 2007 format the error occurred. The metadata from the documents in the office 2003 format were correct.


Has anyone a similar problem or got an idea how to solve this problem?


System Specs:

Frontend: Windows Server 2008 SP2 ent

Storing IP number in a column in db but which column type to use?


I want to store IP number in a column in db but which column type should I use? Of course I can use string but isn't this a waste of storage space? Can I not store IP nr in another type in db that saves space?

How to sort # column in GridView (asp.net) ?


I have a GridView with a column that contains rows numbers. somethign like below :

1    |
2    |
3    |
.     |
.     |
.     |
11  |
12  |
13  |
.    |
.    |
.    |

I've added it to the GridView with the following code :

<asp:TemplateField HeaderText="#" SortExpression="#">
<%# Container.DataItemIndex + 1 %>

Now I wanna sort GridView with this column, I've done it by reading this thread. But when I sort the GridView by # column, it sorts the GridView like below :

1   |
11 |
12 |
.   |
.   |
.   |
21 |
22 |
23 |
.   |
.   |
.   |

How can I fix it

extracting last four characters of a text column and storing it in a number column



is there a way to do the above, for example...I have a text column, Column A containing "172671-08-7892", I need 7892 to be extracted to another column of the type number, from there I need to divide by 2. If the remainder is 0, Column C will be updated as Female, if the remainde is 1, Column C will be updated as Male

Gridview: How to create a column that will autogenerate the serial number of each row


Hi all,

I have a gridview and I want to autopopulate the serial number columns. For eg, the gridview has 10 rows. The user deleted the first row. I want the gridview serial number to automatically shift down by one. Ie., 10-->9, 9-->8 and so on.

Can this be done? Any help is much appreciated!

SQL Server 2008 multiple lines in a varchar(MAX) column?



I'm using varchar(Max) to store a text file content. It's not taking the newline character. I tried \n and char(13) etc.. whatever solution posted in the net.

ex : update test set f='This is line 1.' + CHAR(13) + CHAR(10) + 'This is line 2.' 

after updating it doesn't have any newline or linebreak. Can anyone help me in this how to have linebreaks in the varchar(max) field.

Thanks a lot.

Using Cast and Sum on VarChar Column


Okay, so I have a little problem developing a SQL Select Statement on a column that is formatted pretty badly. Firstly, the Database has already been created and filled with Data in a Test Environment, I'm not sure if the format is the same or has been updated in Production but since I'm only able to work with the Test Environment right now I'm stuck with using what I have. The Column in one Table shows a Snapshot of a clients account which is set to VarChar(50) but the actual data in the column is formatted like a money format (with a $ and decimal point so for example "$5,000.00" would be an entry in one Row). 

What I'm trying to do is a create a WebService that will be used in a iPhone Application and one of the Methods needs to just give a quick display of the total value of all Clients with each specific company but I can't perform a SUM function on a VarChar column and I've tried to CAST and CONVERT the column into money, int, decimal and just about every format I can think of but I keep getting an error stating that I convert the data type varchar to which ever one I'm trying. I think it has something to do with the $ already listed in the Column, so I wanted to know what I could do to either remove the $ sign (like a Trim option) or if there is a better way of doing this that I can't think of.

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