[Excel] Running a SQL Query to delete rows

Hello Experts,
Background: I am attempting to use a dba of my companies time keeping system and implement it with Power BI tools. Given the file size restrictions within Power Bi itself I need to lower my file size by removing all time logs from
inactive employees.
I have a question regarding whether or not you can use a sql query to delete rows in excel. I have roughly 200,000+ rows in my excel spreadsheet. I am attempting to delete all rows where an employee equals inactive. I have attempted to
delete these rows by sorting them and doing a bulk delete and clear contents, but it seems to crash my excel every time.  My thought process is that using a query that does a timed delete might put less of a burden on deleting the massive amount of data.
I would like to use this: DELETE * FROM [Table_(...)_Actual$] WHERE [Current] = "Inactive" (Will add more once I know it is possible to use sql queries in Excel.
Any information on whether or not this is possible would be appreciated.
Regards,
Link

Running SQL Query in Excel is possible, however, the delete query is not supported in Excel.
You are more restricted in deleting Excel data than   data from a relational data source. In a relational database, "row" has no   meaning or existence apart from "record"; in an Excel worksheet, this is not   true. You can delete values
in fields (cells). Please see:http://support.microsoft.com/kb/257819/en-us
One workaround : Use update query to set the rows as null, then use select query.
e.g. 
SQL = "update [sheet2$A1:B5] set name=null,age=null where name='andy'"
cnn.Execute SQL
SQL = "select name,age from [sheet2$A1:B5] where name is not null"
Wind Zhang
TechNet Community Support

Similar Messages

  • How to run recordset SQL query in FORM DATA event

    How can I run recordset SQL query in FORM DATA event upon clicking on Add button in the document?

    Hi Slamet,
    When you receive a form data event you have a class containing inside it a ObjectKeys xml info regarding the object added/modified,...
    With the objects keys you can then use the DI API method called GetByKeys to obtain the DI Object.
    There is some information about it in the SDK Help file, mainly in the "FormDataEvent" class definition:
    <i>The event provides the unique ID (BusinessObjectInfo.ObjectKey) of the modified business object. You can use the value of this property as an input parameter in the DI API DataBrowser.GetByKeys method to get a DI object.</i>
    Pay attention you don't have this information in the Before=True event of the Add as it is not yet in the database.
    Hope it helps
    Trinidad.

  • Query to delete row where column value contains alphabets

    Hi,
    Could anyone please help me to get this query work.
    Query to delete row where column value contains alphabets.
    DELETE  FROM BIN_ITEM WHERE order_nmb LIKE '%[A-Z]%' || LIKE '%[a-z]%'
    Thanks and Regards,
    Deekay.

    RaminHashimzadeh wrote:
    SELECT order_nmb FROM BIN_ITEM WHERE regexp_count(order_nmb,'[0-9]') = 0
    Ramin Hashimzade
    But that won't reject strings like 'gfgG%dgh' which aren't pure alphabetic.
    Try:
    with test_data as (
    select 'ghTYJYEhdfe' str from dual
    union
    select 'dfF5ssd' from dual
    union
    select 'rgth*dgheh' from dual
    union
    select 'ggf{' from dual
    union
    select 'rwhrhrh' from dual
    select  *
    from test_data
    where regexp_instr(str,'[^[:alpha:]]')=0;

  • How to run a sql query from a button in apex 3.0

    Hi,
    I am brand new and went through/installed the obe project tracker. I have need to create a simple application that displays a result (2 fields, name and license number) based on two parameters (dob and login id) which all are stored in 1 table in the database. I could this very simply in VB or VB.net but have no idea how to do it in apex.
    Please provide guidance,
    Thank you,
    Tom

    Hi Tom,
    Sounds like a report region will satisfy your requirements.
    Create a new report region on one of your pages.
    Choose SQL Report and give the region a title.
    When you get to the "Enter SQL Query or PL/SQL function returning a SQL Query:" step, type:
    SELECT name, license_number
    FROM   <insert_your_table_name_here>
    WHERE  dob = :P<n>_dob
    AND    login_id = :P<n>loginid(replace <n> with the page number that the region is on and use your own table name).
    Don't try to run the page yet - it will give 'No data found'
    Now, go back to the Page Definition screen and add two items in the region you just created - call them P<n>dob and P<n>login_id
    Then, create a button in the same region (to be displayed amongst the region's items) - call it P<n>_GO and click 'Create' (take all the other defaults).
    Now you can run the page, put some values into the fields and click go.
    If you want to get fancier, you can change the text items to select lists etc. - let us know if you need help with that.
    Hope this helps,
    Bryan.

  • How to run a SQL query which is stored in a column using PL/SQL?

    Hello
    I have a table A and one of the column values is select * from emp where empno :=xyz;
    Now I would like to call this SQL query using a cursor in PL/SQL and run this for all the empno's and insert them into a temp table.
    Can anybody help me in writing this PL/SQL query?
    With Regards,
    Mohan

    user525114 wrote:
    The primary reason for doing this is we are calculating percentiles on an entity sales for different range periods, and there are several sql queries stored in a cloumn, so we would like to know whether we can run these queries by calling them in a pl/sql query, Its not necessary that we need to use a cursor, but once fetching the result set of the query we would like to insert them in a table.Vamsi,
    As said in response to Satya, executing dynamic SQL, looping over the result set and inserting the results one by one in a temporary table, is a horribly bad idea. Especially in terms of performance, but also regarding the maintainability of your code. It's just way more complex than necessary.
    If you want to calculate percentages, then use analytic or aggregate functions in SQL to do so. If you want to store them, use a single INSERT SELECT statement.
    If you want to continue on the same path, use Satya's code and use it inside a loop.
    Regards,
    Rob.

  • Need help in SQL Query: Update a row in a table & insert the same row into another table

    I want to update a row in a table say Table A and the updated row should be inserted into another table say Table B. I need to do it in a single SQL query and i don't want to do it in PL/SQL with triggers. And i tried with MERGE statement but its working with this scenario. (Note: I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0).
    Thanks in Advance.

    Using Sven's code as an example, you could save the updated row in a sql plus variable. (also untested):
    SQL> var v_id number
    update tableA  
    set colB='ABC' 
    where colC='XYZ' 
    returning id into :v_id;
    insert into table A_History (ID, colA, colB, ColC)  
    select id, ColA, ColB, ColC  
    from tableA  
    where id = :v_id;   

  • Need to run a sql query in the background and display the output in HTML

    Hi Guys,
    I have a link in my iprocurement webpage, when i click this link, a query (sql query) should be run and the output should be displayed in a HTML page. Any ideas of how this can be done. Help appreciated.
    We dont have OA Framework and we r using 11.5.7.
    help needed
    thanx

    Read Metalink Note 275880.1 which has the link to developer guide and personalization guide.

  • When I run my SQL query in MS Access it ask for value ...I don't know why

    Hi,
    Below is my SQL Query:
    SELECT employee.Name, employee.Emplid, payudds.Udds, data.Budget, data.Fund, data.FTE, data.[Annualized Rate], data.[FN Dist Pct], data.Udds, data.Project, data.[Empl Class]
    FROM ((employeeuddslink INNER JOIN employee ON employeeuddslink.[employee_ID] = employee.[ID]) INNER JOIN payudds ON employeeuddslink.[payudds_ID] = payudds.[ID]) INNER JOIN data ON employee.[Emplid] = data.[Emplid]
    GROUP BY employee.Name, employee.Emplid, payudds.Udds, data.Budget, data.Fund, data.FTE, data.[Annualized Rate], data.[FN Dist Pct], data.Udds, data.Project, data.[Empl Class], employeeuddslink.employee_ID, employeeuddslink.payudds_ID;
    When I run this it ask for value for employee.Emplid.
    I just want my query to run.  How do I resolve this.
    Regards, Hitesh

    FROM ((employeeuddslink INNER JOIN employee ON employeeuddslink.[employee_ID] =     
    employee.[ID])      INNER JOIN payudds ON employeeuddslink.[payudds_ID] = payudds.[ID]) INNER JOIN data ON                       
       employee.[Emplid]
    In the FROM you have     employee.[ID]     and    employee.[Emplid]   as both being in table [employee].
    Build a little, test a little

  • Sql query union double rows

    Hi,
    i have a problem with my sql query.
    I need the difference from query 2 - query 1.
    the red marked row should be ignored because its already in table 1.
    Union compares all colums not just the first 3.
    Here's a screen of the problem:
    http://c60.img-up.net/?up=screenoracskt6.JPG
    thx for all

    Hi,
    Welcome to the forum!
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
    Explain how you get those results from that data.
    Always say what version of oracle you're using.
    user6754335 wrote:
    Hi,
    i have a problem with my sql query.
    I need the difference from query 2 - query 1.
    the red marked row should be ignored because its already in table 1.
    Union compares all colums not just the first 3.That's right; UNION compare all the columns selected. If you're only interested in 3 of the columns, then only select those 3.
    If you need to display more columns, but not where all 3 of them match, then the best way is probably an outer join; but there are lots of other ways, including NOT EXISTS, NOT IN, and MINUS (in a sub-query).
    Here's a screen of the problem:
    http://c60.img-up.net/?up=screenoracskt6.JPG
    Post anything relevant on this site.

  • Unable to run Direct SQL Query - Error Odbc driver returned an error (SQLEx

    Hi,
    I have created some answers/reports and dashboards which are working fine.
    However when I try to run an SQL statement on "Create Direct Request" under "Direct Database Request" I get the following error:
    error : State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27022] Unresolved Connection Pool object: "rnd1.Connection Pool". (HY000)
    error : SQL Issued: {call NQSGetQueryColumnInfo('EXECUTE PHYSICAL CONNECTION POOL "rnd1.Connection Pool" select count(*) from dim_issue')}
    I am working as an admin user who has the rights to create direct sql query.
    Any help here will be highly appreciated.
    Thanks, Rohit

    hi,
    27022 Unresolved Connection Pool object: "rnd1.Connection Pool". (HY000
    have you declared correctly your Connention Pool?Or the query you write is it correct?
    check again you connection pool

  • Query for deleting rows older than 25?

    Am trying to delete rows older than 25... How would the query for this be like? I tried this "DELETE FROM DB LIMIT 25,100" But getting errors...

    what is older than 25? Does it mean with id greater then 25?
    then you should have a query like
    DELETE FROM tableName WHERE id > 25

  • Displaying SQL Query results in rows instead of Columns

    Hi,
    I'm fairly new to Oracle so forgive me if this is a really stupid question.
    I used Mysql for a while and if I wanted to display query results in rows instead of columns I could end the SQL command with '\G' instead of a semicolon.
    This would give me output like...
    Column_1: AAAA
    Column_2: BBBB
    Column_3: CCCC
    Instead of the normal
    Column_1 Column_2 Column_3
    AAAAAA BBBBBBB CCCCCCC
    Is there an equivalent in SQLPlus to the MySQL \G termination?
    Thanks.
    John

    > so forgive me if this is a really stupid question.
    It is certainly not a stupid question, but pivoting is a very frequently asked and answered question:
    [url http://forums.oracle.com/forums/search.jspa?threadID=&q=pivot&objID=f75&dateRange=all&userID=&numResults=15]http://forums.oracle.com/forums/search.jspa?threadID=&q=pivot&objID=f75&dateRange=all&userID=&numResults=15
    In 11g you have special PIVOT and UNPIVOT functions.
    Regards,
    Rob.

  • PL/SQL procedure for deleting rows

    We have to delete rows from a table by initiating parallel processes depending on no of connections, and also variable commit frequency. The procedure has to start by itself in case of failure of 1 or more parallel processes, by identifying the position where it stopped. Please some one help me what would be th elogic needed to write the [rocedure.
    Thanks in Advance
    Edited by: 864979 on Jun 9, 2011 10:02 PM

    Be careful of how this is designed and coded. It is very easy to do it horribly wrong, causing contention and problems.
    Have a look at DBMS_PARALLE_EXECUTE.
    If the package is not available on your Oracle version, then look at {message:id=1534900} for a manual approach.

  • Sql query to add row id without loops

    I am aware of the statement SELECT ROW_NUMBER() OVER (ORDER ...
    But we need more functionality. Can we make the row_number to repeat counting from 1 after a specific field changes in value.  I know how to achieve what I want using a cursor within a stored procedure. Is there a way we
    achieve the same just using sql statements and without stored procedure/loop
    For example, we have built the following resultset using an sql query and the result is already sorted by the first field, CompanyName:
    CompanyName, department, ManagerName
    A-company, Account, Steven
    A-company, HR, Mark
    A-company, IT, Susan
    B-Company,IT,Ross
    B-Company,Customer Service, Jack
    C-Company,Finance, Matthew
    C-Company,Finance, Helen
    C-Company,Finance, Ron
    I want to have a rew result with one additional column which is incremented automatically but the value must re-start from 1 once the Companyname changes.
    1, A-company, Account, Steven
    2, A-company, HR, Mark
    3, A-company, IT, Susan
    1, B-Company,IT,Ross
    2, B-Company,Customer Service, Jack
    1, C-Company,Finance, Matthew
    2, C-Company,Finance, Helen
    3, C-Company,Finance, Ron
    Please enlighten me.

    You have to program the numbering yourself. There is no built-in automatic numbering like identity or sequence but only OVER PARTITION BY.
    Reference:
    http://www.sqlusa.com/bestpractices2005/overpartitionby/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Need sql query to convert rows to columns

    Im using oracle 11g.
    I have data in a table as below: Column names are type,month,percentage
    TYPE      MONTH   PERCENTAGE
    A1         JAN-2013     100
    A2         JAN-2013     100
    A3         JAN-2013     95
    A4         JAN-2013     98
    A5         JAN-2013     99
    A6         JAN-2013     90
    A7         JAN-2013     92
    A1         FEB-2013     100
    A2         FEB-2013     99
    A3         FEB-2013     88
    A4         FEB-2013     67
    A5         FEB-2013     98
    A6         FEB-2013     95
    A7         FEB-2013     84
    The desired output using a sql query is as below
    TYPE     JAN-2013     FEB-2013
    A1         100             100
    A2         100             99
    A3         95               88
    A4         98               67
    A5         99               98
    A6         90               95
    A7         92               84

    Try this:
    select * from table_name
    PIVOT(   max(Percentage)
                     for MONTH
                     in ('JAN-2013','FEB-2013')
                     ) ;with data
    with t(TYPE,MONTH,PERCENTAGE) as
    SELECT 'A1', 'JAN-2013', 100
      FROM DUAL
    UNION ALL
    SELECT 'A2', 'JAN-2013', 100
      FROM DUAL
    UNION ALL
    SELECT 'A3', 'JAN-2013', 95
      FROM DUAL
    UNION ALL
    SELECT 'A4', 'JAN-2013', 98
      FROM DUAL
    UNION ALL
    SELECT 'A1', 'FEB-2013', 100
      FROM DUAL
    UNION ALL
    SELECT 'A2', 'FEB-2013', 99
      FROM DUAL
    UNION ALL
    SELECT 'A3', 'FEB-2013', 88
      FROM DUAL
    UNION ALL
    SELECT 'A4', 'FEB-2013', 67
      FROM DUAL
    select * from t PIVOT(   max(Percentage)
                     for MONTH
                     in ('JAN-2013','FEB-2013')
                     ) ;

Maybe you are looking for