.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Separate Consecutive Numbers with Hyphen and Non Consecutive Numbers with Comma

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :


I have a table (myTable) with a single column (myColumn). There are several rows with numbers (integers only) already sorted ascending. What steps would I take to write a SQL statement the would separate consecutive numbers with a hyphen and non consecutive numbers with a comma?


myTable sample










Would have output of: 1-3,5-6,8



View Complete Post

More Related Resource Links

Consecutive Purchase Order Numbers


I'm trying to revamp our current Purchase Order process. In SP2003, the InfoPath form would generate the PO# on the fly by concatenating date+time+initials. This creates a fairly long number though; longer than some vendors web sites will allow, and longer than accounting would prefer.

To implement a consecutive numbering system in SP2007, I created a workflow that kicks off after the InfoPath2010 (non-web) form is submitted that essentially grabs a number from a different list, assigns it to a PO column in the current list, then adds 1 to the first list for the next PO.

I can't figure out how to get the value of that column back onto the InfoPath form when accounting prints it for their records though. Is this possible?

Generate Random Numbers

SQL Server has a built-in function that generates a random number, the RAND() mathematical function. The RAND math function returns a random float value from 0 through 1.

Two numbers after dot



How to do this:

10 becames 10.00

12.3 becames 12.30

14.23 becames 14.23

Thanks you

accept numbers only , telephone validation



my requirement is textbox has to accept only numbers and  " ( ) - " symbols only.

any code plz


Add page numbers for paging in data view web part


Hello all,

Has anyone found a solution that will allow me to have page numbers for paging in a data view web part. For instance, if I have 40 items/rows and I set the paging to display 10 items, I'd like the paging to show 1 2 3 4 rather than showing 1-10 and having to click next over and over to get to a specific item.

I found this article, but it is for 2003 and doesn't seem to apply to 2007 or if it does I am not able to really figure out how.


Please help!

Thanks in advance.


Last numbers from a string


I need a vb function to determine the last numerical characters in a string. For example, if the string is Step1, I need it to return 1. If the string is Step32, I need it to return 32.

I'm aware of the string functions like Right, Instr, etc but I'm just not sure how to get what I need. Any suggestions?

get the string of 6 numbers following a dash and a space

I need to retrieve a string of 6 numbers which following a dash and space e.g - "John Smiley - 023112 - California" I would like to get the "023112" part

Help: Rounding off numbers

I'm having some problems when it comes to rounding off numbers. In the reports I build the users wants to see the numbers in M$ or k? . that is Million$ or kilo?. So what I do is take the money and divide it by 1.000.000 or just by 1.000. The thing is that if a number is 750.000 and I divide it by 1.000.000 it should say 0,75M? for example. But nooo, it says 1M?, and that's not right. Any suggestions?  Thanks in advanced

How to skip page numbers?

I have a SSRS (2005) report with multiple subreports inside of it. Page numbers are displayed on the footer of the "outer" report. After one specific subreport, though, the user wants to have space to insert three pages from a different source, so she wants the page number on the footer to be increased by three. I tried a gazillion things, but it seems that the only possible way is to print three empty pages and replace them (what a waste) before distributing the report. Any suggestion?

Prefix in Numbers

how can i determine prefix of numbers in SQL? for example i want to select records that their ids starts with "123".

RegEx for numbers, letters & underscores only

I have this code:public bool IsAlphaNumeric(String strToCheck){  Regex objAlphaNumericPattern=new Regex("[^a-zA-Z0-9]");  return !objAlphaNumericPattern.IsMatch(strToCheck); } how do I modify the Regex to also accept underscores? 

Order the numbers by value

This seems very basic but I can't seem to find a fast way to do it..I have the following numbers:5, 3, 10, 52, 1I want to order them in the correct format from 1 to 52 and be able to point out which one is the highest, which one is the lowest, which one the second to highest, etc.

Subtracting debits from credits when they are all positive numbers and credit/debit is indicated in

Hi,   I have a table with four columns - InvoiceCreditLineID, SOPOrderReturnLineID, InvoiceCreditQuantity, SOPInvoiceCreditType. The third contains only positive numbers. The fourth contains a 1 for credits and a 2 for debits.   I need to show summed credit quantities minus the summed debit quantities, grouped by SOPOrderReturnLineID. I tried using a sum in a subselect in the select clause for the credit quantities and another for the debit quantities, but this just shows me the totals for the whole table.   Any idea how I do this?

Count numbers of days (no time table in datasource)

I read the following regarding adding a measure for counting the number of days: The trick is to create new measure group, which will have only one dimension - Time, and a measure with Aggregation Type 'Count' bound to the Day attribute of Time dimension (or any other attribute if we need to count something different from days). The most important setting on this new measure group is to leave IgnoreUnrelatedDimensions=true - this will allow to use this measure across any other dimension in the cube. Howerver, this solution assumes that one has a time dimension based on a table in the datasource. I have a Time dimension that created was by the BIDS wizard that is not in my source database but appearantly invisibly hidden on the AS server without direct access to it. (If I try to add a new measure group (as needed according to the post above) then I can only choose from tables that have nothing to do with time). Can somebody explain how I can do this without a specific timetable in my datasource? Do I need to add a timetable just for this purpose? Can it be stand-alone or do I need to add a relationship with all current tables that have date-columns in them? (I am a finance manager that is building a sales cube based on Navision 3.6, which is already working quite nicely, but still very much a newby)

Javascript numbers only, & format it to Decimal

Hello Experts, I need some help guys ;( I want some javascript code that make sure that end user must enter only numbers on textbox (currency,number), no characters, also typed number will be formated to be decimal number, I mean if user type (22222), javascript should format the number to be (22,222.0) javascript function should be called while end user typing on Textbox. so if he enter character, then the character should be removed automatically. I read many posts that talked about this, but most of them are using the onkeypress(event), so if the user paste the text that code will not work. Please help me guys, I need this urgent

changing negative numbers

I have negative numbers in my report and I wish to display them with a "<" sign. How shld i go about doing it?

Use letters instead of numbers for document versions

Is it possible to use letters instead of numbers for document versions? In sharepoint, drafts are numbered 0.1, 0.2,... 1.1, 1.2, 1.3, etc. and published versions are 1.0, 2.0, etc. But due to company's procedures we should use a different system using letters (A, B, C...). Is that possible? If not, would it be possible to add some property to the documents to add the version letter? I know it may be difficult because the letter can be calculated just after sharepoint assigned the version number... :-(
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