+ Reply to Thread
Results 1 to 13 of 13

Removing First Character from SQL Column

Hybrid View

  1. #1
    Registered User
    Join Date
    07-16-2015
    Location
    Tillsonburg, ON
    MS-Off Ver
    MS365 (PC) Version 2210
    Posts
    21

    Removing First Character from SQL Column

    Hello,

    I am trying to run a query from a production database onto a dashboard in the office. My dashboard does not allow special characters such as dollar signs, so i need to remove these special characters within my SQL statement.

    Currently my SQL statement looks like this:
    SELECT SO_Header.Sales_Order, Customer.Sales_Rep, SO_Header.Total_Price, SO_Header.Customer
    FROM PRODUCTION.dbo.Customer Customer, PRODUCTION.dbo.SO_Header SO_Header
    WHERE SO_Header.Customer = Customer.Customer AND ((SO_Header.Order_Date=dateadd(dd,0,datediff(dd,0,getdate()))))

    The column where the special characters are present is (SO_Header.Total_Price)

    Can someone help me how i would modify this statement to remove the first/special characters from this column?

    Please let me know.

    Regards,
    Yorke

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Removing First Character from SQL Column

    Yorke

    What type of database are you running this against?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-16-2015
    Location
    Tillsonburg, ON
    MS-Off Ver
    MS365 (PC) Version 2210
    Posts
    21

    Re: Removing First Character from SQL Column

    It is called JobBOSS...i believe it is a generic ODBC database?
    Would that make sense?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Removing First Character from SQL Column

    You could try SUBSTRING - SUBSTRING(string_exp , start, length)
    SUBSTRING(SO_Header.Total_Price, 2, 10000)
    Note the 10000 is just an arbritrary number for the length.

  5. #5
    Registered User
    Join Date
    07-16-2015
    Location
    Tillsonburg, ON
    MS-Off Ver
    MS365 (PC) Version 2210
    Posts
    21

    Re: Removing First Character from SQL Column

    okay...excuse the ignorance, where would this fit into the SQL statement?

    appreciate your help by the way!

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Removing First Character from SQL Column

    It would replace SO_Header.Total_Price.

    By the way that, if it works of course, will only remove the first character.

    If you have other 'special' characters elsewhere in the field you would need something like REPLACE(string_exp1, string_exp2, string_exp3).

  7. #7
    Registered User
    Join Date
    07-16-2015
    Location
    Tillsonburg, ON
    MS-Off Ver
    MS365 (PC) Version 2210
    Posts
    21

    Re: Removing First Character from SQL Column

    Thanks Norie,

    I did that, now i am getting another error message. Please see attached screenshot.
    Attached Images Attached Images

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Removing First Character from SQL Column

    That must mean Total_Price is some sort of numeric field.

    What are the 'special' characters you want to remove?

    Are they currency symbols?

  9. #9
    Registered User
    Join Date
    07-16-2015
    Location
    Tillsonburg, ON
    MS-Off Ver
    MS365 (PC) Version 2210
    Posts
    21

    Re: Removing First Character from SQL Column

    Okay.

    Yes, i believe it is a currency formatted field. with currency symbols.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Removing First Character from SQL Column

    To deal with this using SQL you'll need to convert the values in the field to text and then apply the functions I've suggested.

    That could become quite complicated.

    Is there no way you can do the import then handle the data in Excel?

  11. #11
    Registered User
    Join Date
    07-16-2015
    Location
    Tillsonburg, ON
    MS-Off Ver
    MS365 (PC) Version 2210
    Posts
    21

    Re: Removing First Character from SQL Column

    okay. yes that sounds complicated.

    I can handle the import into excel without a problem, but the difficulty is getting excel to sync with the dashboard software

    Is there any way that when an excel workbook is closed it will still run an auto refresh every five minutes or so?
    The problem is i need to set the excel workbook up as a data source for my dashboard, so essentially excel will pull the info out of
    the production database, then pass it onto the dashboard software. I have set my excel workbook to refresh into the dashboard on 2
    minute intervals, but i can't get the excel workbook to pull data from the production database on automatic refresh when the workbook is closed.
    DO you have any idea how i could do this?

    Yorke

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Removing First Character from SQL Column

    Why not just cast it to a decimal?
    CONVERT(DECIMAL(18,6), SO_Header.Total_Price)
    å

  13. #13
    Registered User
    Join Date
    07-16-2015
    Location
    Tillsonburg, ON
    MS-Off Ver
    MS365 (PC) Version 2210
    Posts
    21

    Re: Removing First Character from SQL Column

    thanks a lot for the suggestion - but this doesn't seem to work either
    i am beginning to think there is something more underlying this issue.
    Has anyone worked with iDashboards before?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Removing Characters from Right Until Certain Character
    By jam_ran in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-13-2016, 12:19 PM
  2. [SOLVED] Removing Everything After a Character
    By afriedman in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-09-2013, 01:46 AM
  3. [SOLVED] Removing the first 6 character of the id number
    By jamesjessie117 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-17-2012, 05:17 PM
  4. removing a character from a cell
    By wstarkey in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-15-2012, 08:07 AM
  5. Removing Everything After Certain Character
    By rykermason in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-08-2010, 02:56 PM
  6. Bloating when removing $ character
    By Aeetes in forum Excel General
    Replies: 4
    Last Post: 01-25-2007, 12:29 PM
  7. [SOLVED] removing text after a character
    By Kim in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-18-2005, 10:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1