Removing spaces in column names

Hi
I have imported a number of tables from a legacy db. The column names in tables have spaces in them. Is there a script I can run to remove spaces from column names in all tables?
Thanks
Regards

First of all, I do not agree with the concept of changing the column names. There is a good chance of breaking your code, if the table has been referred in procs/functions etc.
One good method would be, import the tables from legacy db into staging and then insert into your actual tables by mapping the tables correctly where your actual table would not have the [space].[Here, I assume your procs/functions etc refer only your actual
tables not staging tables].
OR, if you are looking for a plain logic, then use the below:
The below script wont execute the change, but just would give the statements to be executed to make the column modifications. This is intentional, because this is not a good practice and you can verify the objects and scripts rather than executing it directly.
create table test_table([column test space] int)
--select * From test_table
--Script to do the change in column name
select 'EXEC sp_rename '''+ B.name+'.'+a.name +''', '''+replace(a.name,' ','') +''', ''COLUMN''' from sys.columns A
Inner join sys.tables B on A.object_id = B.object_id and OBJECTPROPERTY(b.object_id, N'IsUserTable') = 1
where
system_type_id in
(select system_type_id From sys.types ) and charindex(' ',a.name)<>0
EXEC sp_rename 'tbl_apas_t_tech.application id', 'applicationid', 'COLUMN'
EXEC sp_rename 'test_table.column test space', 'columntestspace', 'COLUMN'
Drop table test_table
EDIT: Formatting...

Similar Messages

  • Hyperion IR 9.3.1.3:  Spaces in Column Names

    I have a table that has column names that have spaces. Hyperion IR 9.3.1.3 Studio can query this fine, but IR Web Client can't. In Studio, the query log shows the column names surrounded by quotes, but the Web Client won't even show me the query in the query log. Is there a setting I missed when I published the OCE to the Workspace?

    After checking the Use Quoted Identifiers box in the Advanced Options for the connection, the query works, but I still can't use the Detail View option for the table in the data model.

  • How remove space in column ?

    In a.newunit column I have spaces before data. I tried to use TRIM and LTRIM -- but doesn't work :(
    What else I can use?
    SELECT LTRIM(u.scode), LTRIM(a.newunit)
    FROM unit u,
    aaa_test a
    WHERE LTRIM(u.scode) = LTRIM(a.newunit)

    Can you explain what "doesn't work" means, preferrably with an example (i.e. DDL for the Unit and AAA_Test tables, INSERT statements, and a query that returns the incorrect results)?
    TRIM will remove spaces at the beginning and end of a value, LTRIM will remove spaces at the beginning of a value. Potentailly, you don't really have spaces at the beginning of your data. Potentially, you are misinterpreting something (in which case seeing what constitutes "not working" is critical).
    Justin

  • Removing spaces from field names?

    Hi. I'm using Acrobat 9.3.3.
    I use the Form Wizard to create... forms. And a lot of these forms I need to have it do some math calculations -- sums, products, etc. But when I use the Wizard, it auto-creates field names with spaces in them. And (I don't know if this is normal), when I create formulas, notations, scripts, if it's trying to pull from a field with a space in the name it doesn't work.
    I have to go in and manually take out the spaces from all the field names... and there can be a lot of fields!
    Is there some process I'm not seeing, or some way to configure the Wizard, to remove/prevent spaces in the field names?
    Thanks for any info!
    Liam

    I don't believe it is possible.

  • MS Access DB with Spaces in Column Name

    Good Afternoon-
    I'm having some serious headaches with a table that I need to extract information from. The powers that be wrote it with the following column names "Contract Number" , "Customer Number", "Description".
    Note the spaces in the columns.
    Sample code from here: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2691&lngWId=2
    I'm using sample code for connecting to the database and I can access everything using the select statements, except if the column contains a space. I get the following errors:
    s.execute("select [Customer Number], Name from Customer");
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
    s.execute("select \"Customer Number\", Name from Customer");
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
    s.execute("select Customer*Number, Name from Customer");
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
    s.execute("select 'Customer Number' , Name from Customer");
    Data from column_name: Customer Number , Unknown
    This works, but would require parsing-
    s.execute("select * from Customer");
    Data from column_name: 5 , Unknown
    Suggestions would be truly appreciated.
    Jason

    "select [Customer Number] , Name from Customer " ;
    returned the correct responses.Double quoted identifiers, which is part of ANSI SQL should have solved it....
    "select \"Customer Number\" , Name from Customer " ;
    As mentioned above it has certainly been my experience that DBAs (those with that title) all insist that quoted identifiers should never be used. Thus refactoring the database identifiers is actually the correct solution.

  • Cfchart bar graph - removing spaces between columns

    hi
    when we make a bargraph, coldfusion automatically puts
    spacing between the bars... we want continuous bars, with no gaps,
    is this possible ? I have tried pieslicestyle="solid" but that only
    works for Pie graphs...
    for example - I get |||||| - but I want wider lines and no
    space..
    any help will be greatly appreciated.

    Hello, (To view perfectly copy all and paste in editor window)
    No changes..,Actualy the space is between crosstabs.
    i will tell u the layout,
    ______________________________________    //Group Header section starts here
    headding1headding2headding3headding4*
    1st row
    2nd row
    3rd row
    |_4th row______________________________ |     //This is the border of CrossTab
    |                                                                  |     //remove this space
    |                                                                  |     //remove this space
    |                                                                  |     //remove this space
    |+++++++++++++++++++++++++++++++++|     //this is the Group headder Height
    headding1headding2headding3headding4*
    1st row
    2nd row
    3rd row
    |_4th row______________________________ |     //This is the border of CrossTab
    |                                                                  |     //remove this space
    |                                                                  |     //remove this space
    |                                                                  |     //remove this space
    |+++++++++++++++++++++++++++++++++|     //this is the Group headder Height
    I need the layout should be
    headding1headding2headding3headding4*
    1st row
    2nd row
    3rd row
    |_4th row______________________________ |    
    headding1headding2headding3headding4*
    1st row
    2nd row
    3rd row
    |_4th row______________________________ |    
    i had give fit section also...NO CHANGES!!!!
    Edited by: Jebin Manalil on Apr 7, 2009 3:16 PM

  • Special Characters and spaces in Tablenames and Column Names are allowed ?

    Hi
    I have created two tables in Oracle10g
    as follows
    SQL> create table test(columna number,columnb varchar2(20),primary key(columna));
    Table created.
    SQL> insert into test values(1,'test');
    1 row created.
    SQL> commit;
    COMMIT är utfört.
    SQL> create table "test quote"("#" number,abc number,primary key("#"));
    Table created.
    SQL> insert into "test quote" values(1,2);
    1 row created.
    SQL> commit;
    COMMIT är utfört.
    SQL> select * from "test quote";
    # ABC
    1 2
    SQL> select * from test;
    COLUMNA COLUMNB
    1 test
    Now I want to cache the tables and their data into TimesTen
    The cache group for table test which is not having any spaces and special characters in table name and column names is created perfectly.
    But when I create the cache group for table "test quote" which is having special characters and spaces it gives error :
    Command>create readonly cache group w2 from testuser.test(columna number,columnb varchar2(20),primary key(columna));
    Command>select * from test;
    <1,test>
    1 row found.
    Command>create readonly cache group w3 from testuser."test quote"("#" number,abc number,primary key("#"));
    5140: Could not find TESTUSER.TEST QUOTE in Oracle. May not have privileges.
    Command Failed.
    Now there is contradiction that why cache group for table test is created successfully and why it is not being created for table "test quote".
    What I think is if special characters and spaces in column names and table names are possible in Oracle then it sould be possible in TimesTen.
    Any possible solution.
    Looking forward for your reply.
    Please help I am stuck badly.
    /Ahmad

    Hi
    Problem Solved ....... Remeber only Capital letters work with special characters ......
    /Ahmad

  • Removing spaces from multiple files

    I'm using iWeb to make a photogallery, and when i publish to my server on yahoo, it says there is an error. Now i've had tons of errors and problems with yahoo, and i've come to the conclusion that this problem is because the file names have spaces, and yahoo's servers don't like spaces. So, i was wondering how one would go about removing spaces in file names of multiple files in a folder.

    Don't forget that this won't fix any links within the pages themselves.
    If you have a link to "some page.html" and the script renames the file 'some_page.html', you'll need to manually update the links in the page to the new file name before the link will work.

  • Not being remove Blank space in Supplier Name

    Dear,
    Actully we have round more than 200 supplier having supplier name with space due to this client face problem especially in parameter while running reprots or sometime occur in oracle application, therefor i have developed this routine to remove space from the left & right side of suppliername, but not being update although some update get performed when package execute showig status sucessfull & error is blank as mentioned below.
    If any know about to update supplier name in Fron-End, right now we update supplier name but it's not wokrin could y please guide how can we upadate supplier name individulay so we can do it fron-end as per needed.
    DBMS_OUTPUT.PUT_LINE(' STATUS '||v_return_status||' ERROR '||v_error_msg);
    STATUS S ERROR
    declare
    v_return_status varchar2(100); --OUT NOCOPY VARCHAR2,
    v_error_msg varchar2(100); --OUT NOCOPY VARCHAR2);
    begin
    for i in (
    select s.*,par.jgzz_fiscal_code,par.sic_code,par.tax_reference,par.tax_name From ap_suppliers s,hz_parties par
    where ltrim(rtrim(s.vendor_name)) <> s.vendor_name
    and s.vendor_name = par.party_name
    and created_by_module = 'AP_SUPPLIERS_API'
    and vendor_name = 'ABC ' ) loop
    v_return_status := null;
    v_error_msg := null;
    POS_VENDOR_PUB_PKG.Update_Vendor
    p_vendor_id => i.vendor_id ,
    p_segment1 => i.segment1 ,
    p_vendor_name => ltrim(rtrim(i.vendor_name)),
    p_vendor_name_alt => i.vendor_name_alt ,
    p_summary_flag => i.summary_flag ,
    p_enabled_flag => i.enabled_flag ,
    p_segment2 => i.segment2 ,
    p_segment3 => i.segment3 ,
    p_segment4 => i.segment4 ,
    p_segment5 => i.segment5 ,
    p_employee_id => i.employee_id ,
    p_vendor_type_lookup_code => i.vendor_type_lookup_code ,
    p_customer_num => i.customer_num ,
    p_one_time_flag => i.one_time_flag ,
    p_parent_vendor_id => i.parent_vendor_id ,
    p_min_order_amount => i.min_order_amount ,
    p_terms_id => i.terms_id ,
    p_set_of_books_id => i.set_of_books_id ,
    p_always_take_disc_flag => i.always_take_disc_flag ,
    p_pay_date_basis_lookup_code => i.pay_date_basis_lookup_code ,
    p_pay_group_lookup_code => i.pay_group_lookup_code ,
    p_payment_priority => i.payment_priority ,
    p_invoice_currency_code => i.invoice_currency_code ,
    p_payment_currency_code => i.payment_currency_code ,
    p_invoice_amount_limit => i.invoice_amount_limit ,
    p_hold_all_payments_flag => i.hold_all_payments_flag ,
    p_hold_future_payments_flag => i.hold_future_payments_flag ,
    p_hold_reason => i.hold_reason ,
    p_type_1099 => i.type_1099 ,
    p_withhold_status_lookup_code => i.withholding_status_lookup_code ,
    p_withholding_start_date => i.withholding_start_date ,
    p_org_type_lookup_code => i.organization_type_lookup_code ,
    p_start_date_active => i.start_date_active ,
    p_end_date_active => i.end_date_active ,
    p_minority_group_lookup_code => i.minority_group_lookup_code ,
    p_women_owned_flag => i.women_owned_flag ,
    p_small_business_flag => i.small_business_flag ,
    p_hold_flag => i.hold_flag ,
    p_purchasing_hold_reason => i.purchasing_hold_reason ,
    p_hold_by => i.hold_by ,
    p_hold_date => i.hold_date ,
    p_terms_date_basis => i.terms_date_basis ,
    p_inspection_required_flag => i.inspection_required_flag ,
    p_receipt_required_flag => i.receipt_required_flag ,
    p_qty_rcv_tolerance => i.qty_rcv_tolerance ,
    p_qty_rcv_exception_code => i.qty_rcv_exception_code ,
    p_enforce_ship_to_loc_code => i.enforce_ship_to_location_code ,
    p_days_early_receipt_allowed => i.days_early_receipt_allowed ,
    p_days_late_receipt_allowed => i.days_late_receipt_allowed ,
    p_receipt_days_exception_code => i.receipt_days_exception_code ,
    p_receiving_routing_id => i.receiving_routing_id ,
    p_allow_substi_receipts_flag => i.allow_substitute_receipts_flag ,
    p_allow_unorder_receipts_flag => i.allow_unordered_receipts_flag ,
    p_hold_unmatched_invoices_flag => i.hold_unmatched_invoices_flag ,
    p_tax_verification_date => i.tax_verification_date ,
    p_name_control => i.name_control ,
    p_state_reportable_flag => i.state_reportable_flag ,
    p_federal_reportable_flag => i.federal_reportable_flag ,
    p_attribute_category => i.attribute_category ,
    p_attribute1 => i.attribute1 ,
    p_attribute2 => i.attribute2 ,
    p_attribute3 => i.attribute3 ,
    p_attribute4 => i.attribute4 ,
    p_attribute5 => i.attribute5 ,
    p_attribute6 => i.attribute6 ,
    p_attribute7 => i.attribute7 ,
    p_attribute8 => i.attribute8 ,
    p_attribute9 => i.attribute9 ,
    p_attribute10 => i.attribute10 ,
    p_attribute11 => i.attribute11 ,
    p_attribute12 => i.attribute12 ,
    p_attribute13 => i.attribute13 ,
    p_attribute14 => i.attribute14 ,
    p_attribute15 => i.attribute15 ,
    p_auto_calculate_interest_flag => i.auto_calculate_interest_flag ,
    p_validation_number => i.validation_number ,
    p_tax_reporting_name => i.tax_reporting_name ,
    p_check_digits => i.check_digits ,
    p_allow_awt_flag => i.allow_awt_flag ,
    p_awt_group_id => i.awt_group_id ,
    p_pay_awt_group_id => i.pay_awt_group_id ,
    p_awt_group_name => null ,
    p_pay_awt_group_name => NULL ,
    p_global_attribute1 => i.global_attribute1 ,
    p_global_attribute2 => i.global_attribute2 ,
    p_global_attribute3 => i.global_attribute3 ,
    p_global_attribute4 => i.global_attribute4 ,
    p_global_attribute5 => i.global_attribute5 ,
    p_global_attribute6 => i.global_attribute6 ,
    p_global_attribute7 => i.global_attribute7 ,
    p_global_attribute8 => i.global_attribute8 ,
    p_global_attribute9 => i.global_attribute9,
    p_global_attribute10 => i.global_attribute10 ,
    p_global_attribute11 => i.global_attribute11 ,
    p_global_attribute12 => i.global_attribute12 ,
    p_global_attribute13 => i.global_attribute13 ,
    p_global_attribute14 => i.global_attribute14 ,
    p_global_attribute15 => i.global_attribute15 ,
    p_global_attribute16 => i.global_attribute16 ,
    p_global_attribute17 => i.global_attribute17 ,
    p_global_attribute18 => i.global_attribute18 ,
    p_global_attribute19 => i.global_attribute19 ,
    p_global_attribute20 => i.global_attribute20 ,
    p_global_attribute_category => i.global_attribute_category ,
    p_bank_charge_bearer => i.bank_charge_bearer ,
    p_bank_branch_type => i.bank_branch_type,
    p_match_option => i.match_option ,
    p_create_debit_memo_flag => i.create_debit_memo_flag ,
    p_party_id => 2085 ,
    p_parent_party_id => i.parent_party_id ,
    p_jgzz_fiscal_code => i.jgzz_fiscal_code,
    p_sic_code => i.sic_code ,
    p_tax_reference => i.tax_reference,
    p_inventory_organization_id => NULL ,
    p_terms_name => NULL ,
    p_default_terms_id => NULL ,
    p_ni_number => NULL ,
    p_last_update_date => NULL ,
    x_return_status => v_return_status,
    x_error_msg => v_error_msg
    DBMS_OUTPUT.PUT_LINE(' STATU S '||v_return_status||' ERROR '||v_error_msg);
    end loop;
    end;
    Edited by: oracle0282 on Dec 24, 2011 3:36 AM
    Edited by: oracle0282 on Dec 25, 2011 9:51 PM

    Just a thought..
    How about creating a new supplier and then opt for Supplier Merge?
    Using supplier merge you may transfer all the open PO's and invoices of the old supplier to the new
    supplier. By using the supplier merge, the old supplier would be end date automatically by the
    system.
    P.S. I am NOT sure whether there exist a datafix to edit the supplier name.
    Regards,
    Srini

  • List View - Remove Group By Headers - Column Names

    I have a List View web part using Group By. However, when you do that, it uses the Actual column name with a colon in the visual representation.
    Also, there is a bar with the name of the column showing.
    I don't want to have either of these showing. I have found pages on the net that tell you how to do this using SPD, but because that causes unghosting, we don't use SPD.
    Also, I found this, using Javascript:
    http://amitphule.blogspot.com/2011/10/hiding-group-headers-from-sharepoint.html
    This works. However, it removes the Editing components of the ribbon also - you can't go back later and do any editing.
    Does anyone have any other ideas on this?

    Hi,
    According to your post, my understanding is that you wanted to remove Group By Headers in the List View web part.
    I try to reproduce the issue using the code you provided, however, I can edit the items.
    The initial status:
    The final status:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to resolve unresolved column error when we change column name in BMM Layer and removed alias in presentation layer

    how to resolve unresolved column error when we change column name in BMM Layer and removed alias in presentation layer

    Looks like the presentation column got Alias before your BMM changes, so in your case renaming logical column and deleting alias is not good to go.
    Keep Alias

  • How do I remove spaces and special characters from the file name during rendering?

    I understand that I can set LR_renamingTokensOn to true, but I would like to replace all spaces in the file name with an underscore and remove characters not in the range A-Z and 0-9. What's the easiest way to achieve this?

    local photo = catalog:getTargetPhoto()
    local sesn = LrExportSession {
        photosToExport = { photo },
        exportSettings = {
            -- ... (determine from export preset) - whatev you want, just be sure you set export directory: LR_export_destinationPathPrefix
            LR_tokens = "{{custom_token}}",
            LR_tokenCustomString = LrPathUtils.removeExtension( photo:getFormattedMetadata( 'fileName' ) ):gsub( "[ %c]", "" ) -- remove spaces and control characters
    sesn:doExportOnNewTask()

  • How to remove column name in select clause

    Hello Guys,
    I just want to remove a column name in select clause. Because, I don't want to write all column names. I hope I express myself.
    In other words, I want the following.
    Select   * - unwanted_column  from table;
    instead of this
    Select col1, col2, col3, col4, ........ col 10000 from table;

    Hi,
    Sorry, there's nothing in SQL that means "all columns *except* ...". As the others have said, the only way to get those results in SQL is to list all the columns you do want.
    Your front end may have some feature that allows you to hide a specific column. For example, in SQL*Plus, you can use <tt> COLUMN ... NOPRINT </tt> , like this:
    COLUMN      dname     NOPRINT
    SELECT       *
    FROM       scott.dept
    ORDER BY  dname
    ;Output:
    `   DEPTNO LOC
            10 NEW YORK
            40 BOSTON
            20 DALLAS
            30 CHICAGOThere is a column called dname in the scott.dept table; the query above actually uses it. But, because of the COLUMN command, SQL*Plus won't display that column.
    Edited by: Frank Kulash on Feb 26, 2013 10:10 AM
    Changed scott.dept example.

  • SQL Query not working for column names with spaces

    Hi People..
    We have a strange situation wherein, the column name in the database table has a space inbetween like "Constant Name". While we write a JDBC statement code with the select query we get an exception for invalid syntax. It will help us in a great way if you have anything to inform us on this..
    Thanks
    Prabz

    Using case sensitive names and names with spaces in it is not a good practice.
    However, I believe the SQL standard accounts for this with quoted identifiers. I believe the syntax is
    . select "My Field1", "My Field2"
    . from "My Table'
    Have also seen the following although it might be MS Access specific.
    . select [My Field1], [My Field2]
    . from [My Table]

  • ACCESS column names containing spaces

    Hi
    I'm new to Java SQL programming and have come across a problem I can't seem to fix reharding ACCESS column names that contain spaces.
    Here's the actual code :
    sqlquery = "select * from cars,qualify where group2 = '" + addComponentsToDrivers.currentgroupcode + "' and cars.car id no = qualify.car id no";
    here's the error java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'group2 = 'INTGT5' and cars.car id no = qualify.car id no'.
    The question is how can I code qualify.car id no?
    Thanks
    Ken

    and cars.car id no = qualify.car id noand cars.[car id no] = qualify.[car id no]

Maybe you are looking for