Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

SQL data manipulation

  • 11-01-2011 11:13am
    #1
    Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭


    I have a SQL statement, INSERT INTO.. (SELECT FROM...) which transfers information between two tables. Issue I have is that in the Source table the VAT column contains data in the format .21, .135 etc but in the target column I want the data in the format 21, 13.5 or (21.00, 13.50) etc.

    Both Source & Target columns are numeric, I've attempted to look at this in two ways;

    Can I format the data correctly as part of the INSERT INTO statement or
    Can I format the data post import with an UPDATE statement.

    Haven't come up with a solution either way. Is this possible with the limited amount of built in SQL (2008) functions?


Comments

  • Registered Users, Registered Users 2 Posts: 1,657 ✭✭✭komodosp


    Can you not just add another statement to run afterwards:

    UPDATE newtable set VAT = VAT * 100

    ??


  • Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭CountingCrows


    komodosp wrote: »
    Can you not just add another statement to run afterwards:

    UPDATE newtable set VAT = VAT * 100

    ??

    Ah FFS!!! Can't see the wood from the tress - thanks.


  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    I have a SQL statement, INSERT INTO.. (SELECT FROM...) which transfers information between two tables. Issue I have is that in the Source table the VAT column contains data in the format .21, .135 etc but in the target column I want the data in the format 21, 13.5 or (21.00, 13.50) etc.

    Both Source & Target columns are numeric, I've attempted to look at this in two ways;

    Can I format the data correctly as part of the INSERT INTO statement or
    Can I format the data post import with an UPDATE statement.

    Haven't come up with a solution either way. Is this possible with the limited amount of built in SQL (2008) functions?

    Ahhhhh multiply by 100 as your inserting...
    INSERT
       TableA
       (VAT)
    SELECT 
       VAT * 100 
    FROM 
       TableB
    


  • Registered Users, Registered Users 2 Posts: 523 ✭✭✭mwrf


    Haven't come up with a solution either way. Is this possible with the limited amount of built in SQL Server (2008) functions?

    FYP
    Sorry, Gets my goat


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    Is this possible with the limited amount of built in SQL (2008) functions

    what sort of statement is this? SQL 2008 most likely has all the statements you will ever need.
    What exactly can't you do in SQL 2008 that you can do in the other databases that you have extensive experience of?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭CountingCrows


    amen wrote: »
    what sort of statement is this? SQL 2008 most likely has all the statements you will ever need.
    What exactly can't you do in SQL 2008 that you can do in the other databases that you have extensive experience of?

    Problem is solved (see above) and was very basic. Until I saw the light I thought I would have to use string function to find the decimal point and then perform a calculation.


Advertisement