Results 1 to 6 of 6

Thread: Sql Server Express Auto Column

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Sql Server Express Auto Column

    Thisis my first shot at working with creating own sql database

    I want to create a column of interest rates from .125 % to 21 % incremented by .125%

    Is there a way to "auto" create the column so i dont have to type in each rate

    And can you store percentages in a sql database? or should it be a decimal, then format before display

    Thanks for any feedback and help

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sql Server Express Auto Column

    This gives a result from 0.123 to 21
    Code:
    ; WITH aa AS (
    	SELECT CAST(0.125 AS FLOAT) AS Num
    	
    	UNION ALL
    	
    	SELECT CAST(Num + 0.125 AS FLOAT)
    	FROM aa
    	WHERE Num < 21
    )
    SELECT *
    FROM aa
    OPTION (MAXRECURSION 0)

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Sql Server Express Auto Column

    Thanks, I should have been more specific and said at design time
    I am adding a table to my database that will store these numbers that my dopdownlist will contain so the user at run time cant mis-type wrong data.

    It just seems silly to have to manually enter each one in

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Sql Server Express Auto Column

    If the user is going to enter - at run time - the table values - how else could you get them into a table??

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Sql Server Express Auto Column

    Quote Originally Posted by szlamany View Post
    If the user is going to enter - at run time - the table values - how else could you get them into a table??
    In my second post I said at "Design time" user will not be entering the values
    Again I apologize for not being more specific in my initial post

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Sql Server Express Auto Column

    well you can use the query that CVM supplied to INSERT INTO your table...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width