How to get index fragmentation percentage by sql query

hi, experts, I built some indexes in my database. the database is not accessible by me. it is by DBA. I could not ask him to use interface on management studio to check every indexes fragmentation percentage everyday. is there any sql queries to get the  index
fragmentation percentage?
then I could write a sql and execute from a windows scheduler to export report everyday.
the sql server version is 2005
Thank you very much!

hi
check this link: http://gallery.technet.microsoft.com/scriptcenter/Check-SQL-Server-a-a5758043
SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,
ind.name AS IndexName, indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind
ON ind.object_id = indexstats.object_id
AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30
ORDER BY indexstats.avg_fragmentation_in_percent DESC
[Personal Site] [Blog] [Facebook]

Similar Messages

  • How to get row count of a sql query

    After firing a query, how can i get the number of records returned by the query from the database, it should be database indipendent.
    Statement stmt = conn.createStatement();
                      stmt.executeQuery(query);After this I want the number of row i.e. the number of records returned by the database.

    Number of rows in a ResultSet may be obtained with:
    ResultSet rs;
    int numRows=rs.last().getRow();
    I would have said this too, as a matter of fact I mentioned scrollable result sets in my post, but as I said, not all drivers support this, and he said he needed it to be database independent, so this method should not be used.

  • How to get the desire output from sql query

    Consider an Order Table: ...
    Order Table:
    Order Id Item Qty
    O1 A1 5
    O2 A2 1
    O3 A3 3
    Please provide SQL which will explode the above data into single unit level records as shown below
    Desired Output:
    Order Id Order Id Qty
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O2 A2 1
    O3 A3 1
    O3 A3 1
    O3 A3 1

    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • How to view Index fragmentation in sap ecc6 ?

    how to view Index fragmentation in sap ecc6 ?

    Hi Haimiao,
    You can use brtools to get required information. For relevant steps use the link below
    https://help.sap.com/saphelp_nw04/helpdata/en/08/5742154ae611d1894f0000e829fbbd/content.htm
    Regards,
    Deepak Kori

  • How to get Listener Information using PL/SQL code

    How to get Listener Information using PL/SQL code

    user2075318 wrote:
    How to get Listener Information using PL/SQL codeThis approach (somewhat of a hack) can be used - but it does not really provide meaningful data at application layer.
    SQL> create or replace function TnsPing( ipAddress varchar2, port number default 1521 ) return varchar2 is
      2          type THexArray is table of varchar2(2);
      3          --// tnsping packet (should be 10g and 11g listener compatible)
      4          TNS_PING_PACKET constant THexArray := new THexArray(
      5                  '00', '57', '00', '00', '01', '00', '00', '00',
      6                  '01', '39', '01', '2C', '00', '00', '08', '00',
      7                  '7F', 'FF', '7F', '08', '00', '00', '01', '00',
      8                  '00', '1D', '00', '3A', '00', '00', '00', '00',
      9                  '00', '00', '00', '00', '00', '00', '00', '00',
    10                  '00', '00', '00', '00', '00', '00', '00', '00',
    11                  '00', '00', '00', '00', '00', '00', '00', '00',
    12                  '00', '00', '28', '43', '4F', '4E', '4E', '45',
    13                  '43', '54', '5F', '44', '41', '54', '41', '3D',
    14                  '28', '43', '4F', '4D', '4D', '41', '4E', '44',
    15                  '3D', '70', '69', '6E', '67', '29', '29'
    16          );
    17 
    18          socket  UTL_TCP.connection;
    19          txBytes number;
    20          rxBytes number;
    21          rawBuf  raw(1024);
    22          resp    varchar2(1024);
    23  begin
    24          socket := UTL_TCP.open_connection(
    25                          remote_host => ipAddress,
    26                          remote_port => port,
    27                          tx_timeout => 10
    28                  );
    29 
    30          --// convert hex array into a raw buffer
    31          for i in 1..TNS_PING_PACKET.Count loop
    32                  rawBuf := rawBuf || HexToRaw( TNS_PING_PACKET(i) );
    33          end loop;
    34 
    35          --// send packet
    36          txBytes := UTL_TCP.write_raw( socket, rawBuf, TNS_PING_PACKET.Count  );
    37 
    38          --// read response
    39          rxBytes := UTL_TCP.read_raw( socket, rawBuf, 1024 );
    40 
    41          UTL_TCP.close_connection( socket );
    42 
    43          --// convert response to varchar2
    44          resp := UTL_RAW.Cast_To_Varchar2( rawBuf );
    45 
    46          --// strip the header from the response and return the text only
    47          return( substr(resp,13) );
    48  end;
    49  /
    Function created.
    SQL>
    SQL> select tnsping( '10.251.93.30' ) as TNSPING from dual;
    TNSPING
    (DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=0)(ALIAS=LISTENER))
    SQL> select tnsping( '10.251.95.69' ) as TNSPING from dual;
    TNSPING
    (DESCRIPTION=(TMP=)(VSNNUM=0)(ERR=0)(ALIAS=LISTENER))
    SQL>

  • How to replace a dates on a SQL query on Visual Studio (and get the query to work in there in the first place)?

    Morning all,
    I've just been assigned a report-related project but I have not created much of anything in C# or .Net before!
    I was wondering if someone could help me get started. Here are the specifications:
    Basically, I am to create an automated report application. I have the query and I will include it further down
    in this post. The page is to have a couple blanks to specify the Start Date and End Date and replace those dates in the query, and generate the report. What I need some help on is how to make the SQL query work in the application which I will connect to the
    intended database to generate the report (basic I know, but I'm new at this) on Visual Studio 2010. I also need some help on programming the Start Date blank and End Date blank so that what the user types in for those blanks will replace the date fields in
    the SQL query, then generate the report with the new dates. 
    I appreciate the help!
    The SQL query and what the dates are replacing:
    select 
    PTH.INST_ID ,
    PTH.EMPLOYEE_ID,
    DBH.HR_DEDUCTION_AND_BENEFITS_CODE,
    replace(DB.DESCRIPTION,',',''),
    DB.WITHHOLDING_LIABILITY_ACCOUNT_MASK,
    DBH.HR_DEDUCTION_AND_BENEFITS_ID,
    DBH.CHECK_DATE,
    DBH.CHECK_NO,
    DBH.FIN_INST_ACCT_ID,
    replace(replace (DBH.COMMENT,CHAR(10),' '),CHAR(13),' '),
    DBH.HR_DEDUCTION_AND_BENEFIT_CYCLE_CODE,
    DBH.LENGTH,
    DBH.EMPLOYEE_COMPUTED_AMOUNT,
    DBH.EMPLOYEE_BANK_ROUTING_NUMBER,
    DBH.EMPLOYEE_ACCOUNT_TYPE,
    DBH.EMPLOYEE_ACCOUNT_NUMBER,
    DBH.EMPLOYER_COMPUTED_AMOUNT,
    DBH.EMPLOYEE_GROSS_AMOUNT,
    DBH.EMPLOYER_GROSS_AMOUNT,
    DBH.PAYROLL_EXCLUDE,
    PTH.VOID_DATE,
    PTH.BATCH_QUEUE_ID,
    B.BATCH_CODE,
    BQ.FY,
    BQ.END_DATE,
    BQ.COMMENTS,
    BQ.BATCH_CRITERIA_USED,
    BP.COLUMN_VALUE,
    PTH.REPLACEMENT,
    P.LAST_NAME,
    P.FIRST_NAME,
    P.MIDDLE_NAME
    from PY_EMPLOYEE_TAX_HISTORY PTH
    INNER JOIN PERSON_EMPLOYEE PE ON
    PE.INST_ID=PTH.INST_ID AND
    PE.EMPLOYEE_ID=PTH.EMPLOYEE_ID
    INNER JOIN PERSON P ON
    PE.INST_ID=P.INST_ID AND
    PE.PERSON_ID=P.PERSON_ID
    LEFT JOIN HR_EMPLOYEE_DEDUCTIONS_AND_BENEFITS_HISTORY DBH ON
    PTH.INST_ID=DBH.INST_ID AND
    PTH.CHECK_DATE=DBH.CHECK_DATE AND
    PTH.CHECK_NO=DBH.CHECK_NO AND
    PTH.EMPLOYEE_ID=DBH.EMPLOYEE_ID
    LEFT JOIN HR_DEDUCTION_AND_BENEFITS DB ON
    DB.INST_ID=DBH.INST_ID AND
    DB.HR_DEDUCTION_AND_BENEFITS_CODE=DBH.HR_DEDUCTION_AND_BENEFITS_CODE
    LEFT JOIN BATCH_QUEUE BQ ON
    PTH.BATCH_QUEUE_ID=BQ.BATCH_QUEUE_ID
    LEFT JOIN BATCH B ON
    B.BATCH_CODE=BQ.BATCH_CODE 
    LEFT JOIN BATCH_PARAMETER BP ON
    BQ.BATCH_QUEUE_ID=BP.BATCH_QUEUE_ID
    AND BP.COLUMN_NAME = 'SUPPRESS_DIRECT_DEPOSIT'
    ------Please change the WHERE condition for date range of the month you need to run this for.
    WHERE PTH.CHECK_DATE >='07/01/2013'
    AND PTH.CHECK_DATE <='07/31/2013'
    and BQ.BATCH_CODE='BAT_PY_PAYCALC'
    and bq.fy=2014
    ORDER BY PTH.INST_ID ,
    PTH.EMPLOYEE_ID,
    DBH.HR_DEDUCTION_AND_BENEFITS_CODE,
    DBH.CHECK_DATE

    Try this code.  The Server name will be the same name when you use SQL Server Management Studio (SSMS).  It is in the login window for SSMS.  I assume you are using SQLSTANDARD (not SQLEXPRESS) which is in the connection string in the code
    below. I also assume you have remote connection allowed in the database.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;
    namespace ConsoleApplication1
    class Program
    const string DATABASE = "Enter Database Name Here";
    const string SERVER = "Enter Server Name Here";
    static void Main(string[] args)
    DateTime startDate = DateTime.Parse("07/01/2013");
    string startDateStr = startDate.ToString("MM/dd/yyyy");
    DateTime endDate = new DateTime(startDate.Year, startDate.Month + 1, 1).AddDays(-1);
    string endDateStr = endDate.ToString("MM/dd/yyyy");
    string connStr = string.Format("Server={0}\\SQLSTANDARD;Database={1};Trusted_Connection= True;", SERVER,DATABASE);
    string SQL = string.Format(
    "select\n" +
    " PTH.INST_ID\n" +
    ",PTH.EMPLOYEE_ID\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFITS_CODE,\n" +
    ",replace(DB.DESCRIPTION,',','')\n" +
    ",DB.WITHHOLDING_LIABILITY_ACCOUNT_MASK\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFITS_ID\n" +
    ",DBH.CHECK_DATE\n" +
    ",DBH.CHECK_NO\n" +
    ",DBH.FIN_INST_ACCT_ID\n" +
    ",replace(replace (DBH.COMMENT,CHAR(10),' '),CHAR(13),' ')\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFIT_CYCLE_CODE\n" +
    ",DBH.LENGTH\n" +
    ",DBH.EMPLOYEE_COMPUTED_AMOUNT\n" +
    ",DBH.EMPLOYEE_BANK_ROUTING_NUMBER\n" +
    ",DBH.EMPLOYEE_ACCOUNT_TYPE\n" +
    ",DBH.EMPLOYEE_ACCOUNT_NUMBER\n" +
    ",DBH.EMPLOYER_COMPUTED_AMOUNT\n" +
    ",DBH.EMPLOYEE_GROSS_AMOUNT\n" +
    ",DBH.EMPLOYER_GROSS_AMOUNT\n" +
    ",DBH.PAYROLL_EXCLUDE\n" +
    ",PTH.VOID_DATE\n" +
    ",PTH.BATCH_QUEUE_ID\n" +
    ",B.BATCH_CODE\n" +
    ",BQ.FY\n" +
    ",BQ.END_DATE\n" +
    ",BQ.COMMENTS\n" +
    ",BQ.BATCH_CRITERIA_USED\n" +
    ",BP.COLUMN_VALUE\n" +
    ",PTH.REPLACEMENT\n" +
    ",P.LAST_NAME\n" +
    ",P.FIRST_NAME\n" +
    ",P.MIDDLE_NAME\n" +
    " from PY_EMPLOYEE_TAX_HISTORY PTH\n" +
    " INNER JOIN PERSON_EMPLOYEE PE ON\n" +
    " PE.INST_ID=PTH.INST_ID AND\n" +
    " PE.EMPLOYEE_ID=PTH.EMPLOYEE_ID\n" +
    " INNER JOIN PERSON P ON\n" +
    " PE.INST_ID=P.INST_ID AND\n" +
    " PE.PERSON_ID=P.PERSON_ID\n" +
    " LEFT JOIN HR_EMPLOYEE_DEDUCTIONS_AND_BENEFITS_HISTORY DBH ON\n" +
    " PTH.INST_ID=DBH.INST_ID AND\n" +
    " PTH.CHECK_DATE=DBH.CHECK_DATE AND\n" +
    " PTH.CHECK_NO=DBH.CHECK_NO AND\n" +
    " PTH.EMPLOYEE_ID=DBH.EMPLOYEE_ID\n" +
    " LEFT JOIN HR_DEDUCTION_AND_BENEFITS DB ON\n" +
    " DB.INST_ID=DBH.INST_ID AND\n" +
    " DB.HR_DEDUCTION_AND_BENEFITS_CODE=DBH.HR_DEDUCTION_AND_BENEFITS_CODE\n" +
    " LEFT JOIN BATCH_QUEUE BQ ON\n" +
    " PTH.BATCH_QUEUE_ID=BQ.BATCH_QUEUE_ID\n" +
    " LEFT JOIN BATCH B ON\n" +
    " B.BATCH_CODE=BQ.BATCH_CODE\n" +
    " LEFT JOIN BATCH_PARAMETER BP ON\n" +
    " BQ.BATCH_QUEUE_ID=BP.BATCH_QUEUE_ID\n" +
    " AND BP.COLUMN_NAME = 'SUPPRESS_DIRECT_DEPOSIT'\n" +
    " WHERE PTH.CHECK_DATE >='{0}'\n" +
    " AND PTH.CHECK_DATE <='{1}'\n" +
    " and BQ.BATCH_CODE='BAT_PY_PAYCALC'\n" +
    " and bq.fy=2014\n" +
    " ORDER BY PTH.INST_ID\n" +
    ",PTH.EMPLOYEE_ID\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFITS_CODE\n" +
    ",DBH.CHECK_DATE", startDateStr, endDateStr);
    SqlDataAdapter adapter = new SqlDataAdapter(SQL, connStr);
    DataTable dt = new DataTable();
    adapter.Fill(dt);
    jdweng
    Could you elaborate more on what this code does in general?
    Does it generate a table with the data between specified dates? If so, where is the table shown? 
    Where does one enter in the specified start and end dates on the Web Application? Do I have to create start and end date blanks and link them to the code for it to work?
    Sorry for the inconvenience - I'm just really new at this. Thanks!

  • How to get rid of quotes in SQL?

    Hi All!
    Does anybody know how to get rid of quotes in
    generated SQL? I don't mean manual editing.
    Are there any properties controlling this
    behavior (adding "" automatically)?
    Thanks in advance!
    Sincerely,
    Lev

    Use PreparedSatement class,
    e.g.
    // Where the name field is defined as char, i.e. needs quotes in SQL.
    String sql = "select * from person where name = ? ";
    PreparedStatement statement = connection.prepareSatement(sql);
    statement.setString(1, "Bob");
    statement.executeQuery();
    This will get rid of hardcoding db vendor dependant quotes in your sql,
    Hope this helped.

  • How to get information from desktops into SQL?

    Hello Everyone,
    I could use some help with an idea that I have been working on. I basically am looking for a way to capture information from desktops and get that data into a SQL database. Could anyone give me any links, kb articles, etc on how I can go about doing this?
    Any help would be very appreciated
    Thanks :)

    Powershell is the tool for you. If you could please move this post to powershell; you should get better response.  I almost certain that there are already some powershell scripts that does this, or at least will give you a report or a excel\csv file
    with this information.
    once you have that info you import that data into sql and sql server agent jobs you can automate. 
    Below are some of the resources :
    http://serverfault.com/questions/585223/how-to-list-all-computers-operating-system-on-a-network-in-powershell
    https://www.simple-talk.com/sql/database-administration/let-powershell-do-an-inventory-of-your-servers/
    http://gallery.technet.microsoft.com/scriptcenter/Hardware-Inventory-Using-fe6611e0
    http://blogs.technet.com/b/heyscriptingguy/archive/2006/11/09/how-can-i-use-windows-powershell-to-get-a-list-of-all-my-computers.aspx
    Again, please move this powershell thread. you will get better response,
    Hope it Helps!!

  • How to get index of the item from table when user double click on an item

    Can anyone tell me how to get the corresponding index of a table in which
    elements are listed as array of strings? I am looking for the index of the
    item being double-clicked on?
    Thank you in advance
    Cheers,
    NQ.

    Hi NQ,
    Although the question is not thouroughly clear, I can give a few suggestions. You can use the property node for table to refer to any particular row or column of the table. The correpsonding elements in the property node will be "SelStart", "SelSize" etc. Just as a side thought, the index of a table starts with (0,0).
    I am attaching a test file. Please see if it helps you in figuring out what exactly you want. This example VI is just to help you try different options under property node (if you havent already tried)to get what you want.
    Regards,
    Sastry Vadlamani
    Applications Engineer
    National Instruments
    Attachments:
    test.vi ‏27 KB

  • How to get Index storage Quality

    Hi,
    I want to get the storage quality of the Index for multiple Indexes.
    I am albe to get the Index Quality for particular one Index by accessing following path.
    DB02OLD -> Tables and Indexes -> Detailed Analysis -> Enter Index Name -> Detailed Analysis
    Check storage quality by, Analyze Index -> Storage Quality
    By accessing above path i have to check index one by one and its take very long time.
    But I want to check the storage Quality for multiple Indexes at same time.
    So is it possible to get Index Storage quality for miltiple indexes in single steps?
    Regards,
    Nisit

    Hi Nisit Patel ,
    If u have found the solution please share with me
    as i also need to analyse the % of storage quality from mulitple indexes
    is there any sql script for the same
    thanks
    Anand

  • How to get columns horizontal in pl/sql procedure

    My task is I want to retrieve all the Insert Statements of the rows that are present in each table of a particular Schema.
    When I give input as Schema name(Scott) in a Procedure, Then the procedure retrieves all the Insert statements of rows of all tables that are present in scott user.
    For this I started like this
    CREATE OR REPLACE PROCEDURE MYPROC(UID DBA_OBJECTS.OWNER%TYPE)
    AS
    CURSOR MYCUR IS select o.owner, o.object_name,c.column_name
    from dba_objects o, dba_tab_cols c where o.owner=c.OWNER(+) AND O.OWNER=UID
    AND O.OBJECT_NAME=C.TABLE_NAME AND ROWNUM<20 AND O.OBJECT_TYPE='TABLE';
    BEGIN
    FOR EREC IN MYCUR LOOP
    DBMS_OUTPUT.PUT_LINE('insert into '||erec.object_name||'('||erec.column_name||')'||'values(');
    END LOOP;
    END MYPROC;
    When I execute this procedure I got the result as follows.
    EXEC MYPROC('SCOTT');
    insert into DEPT(DEPTNO)values(
    insert into DEPT(DNAME)values(
    insert into DEPT(LOC)values(
    insert into EMP(EMPNO)values(
    insert into EMP(ENAME)values(
    insert into EMP(JOB)values(
    insert into EMP(MGR)values(
    insert into EMP(HIREDATE)values(
    insert into EMP(SAL)values(
    insert into EMP(COMM)values(
    insert into EMP(DEPTNO)values(
    insert into BONUS(ENAME)values(
    insert into BONUS(JOB)values(
    insert into BONUS(SAL)values(
    insert into BONUS(COMM)values(
    insert into SALGRADE(GRADE)values(
    insert into SALGRADE(LOSAL)values(
    insert into SALGRADE(HISAL)values(
    insert into PROJECT(PNO)values(
    As you see the columns are coming in line by line.
    Now My question is I want the columns of each table to come in only One Insert Statement.i.e. one insert statement for one table. All columns of one table should in one row. How to do this?
    Please Help me
    Thanks in Advance.

    Hi,
    two loops works the easiest way
    CREATE OR REPLACE PROCEDURE MYPROC(UID DBA_OBJECTS.OWNER%TYPE)
    AS
    CURSOR MYtab
    IS
    select o.owner, o.object_name
    from dba_objects o where O.OWNER=UID
    and ROWNUM<20
    AND O.OBJECT_TYPE='TABLE';
    CURSOR MYCol(b_owner varchar2,b_table varchar2)
    IS
    select c.column_name
    from dba_tab_cols c where c.owner=b_OWNER AND b_table=C.TABLE_NAME;
    l_line varchar2(2000);
    begin
      for r_tab in mytab
    loop
      l_line :='insert into '||r_tab.object_name||'(');
      for r_col in mycol(r_tab.owner,r_tab.object_name)
      loop
        l_line := l_line||r_col.column_name||',';
      end loop;
      l_line := rtrim(l_line,',')||') values (';
    dbms_output.put_line(l_line);
    end loop;
    end;Hope this will give you some insights how to get the results.
    Herald ten Dam
    Superconsult.nl

  • How to get better performance to this sql code?

    Guys I need your help.
    I have a master table, 80 columns, more than millions data in it.
    MasterTable
    PK_Column_1
    PK_Column_2
    Column_3
    Column_4
    Select column_3, column_4
    from MasterTable
    where PK_Column_1 = '1' and PK_Column_2 = '2';
    I don't know how to create index for this table. Thank u.

    I don't know how to create index for this table.If PK stands for Primary Key, there should already be an index on those columns.
    What trouble are you having? Have you looked at an explain plan?
    Also...
    PK_Column_1 = '1' Are your primary key columns varchar2 columns?

  • How to get hardware related metrics of SQL Server through query ?

    Hi Folks,
                   I am newbie to the SQL Server programming. I also follow this forum only now. I am not sure if these kind of question had been asked in the past. Let me furnish you more detail about my query. I do like
    to get few details regarding the SQL server. I do need the following details to get the information about it through query
    SQL Server Installation directory
    No. Of CPU(as i read SQL Server standard support 4 cpu and Enterprise support 32 CPU)
    CPU Speed of the SQL Server installed machine
    Disk Storage details
    Operating system on which the SQL Server is installed
    Location of the swap file of SQL Server
    TempDB directory path
    System database directory path
    User database location 
    Log files location
    I do like to get information like this through query. Can i know if such information can be get through query or it should be get only thro' WMI. Please drop your ideas in getting these details.
    Thanks in Advance,
    Regards,
    JeiSurya

    Try this query in the below link 
    http://gallery.technet.microsoft.com/Query-to-find-all-the-8fa765e6
    you will get the SQL Server and H/W Details like 
    IP Address 
    FQDN 
    CurrentSQLNodeName 
    SQL Instance Name 
    SQL Server Product
    SQL Server Edition 
    Service Pack 
    SQL Server Version 
    Operating System
    OS SP Level
    OS Build Number
    SystemManufacturer 
    Processor Type 
    System Model 
    Total RAM in MB 
    NumberOfPhysicalCPUs 
    NumberOfCoresInEachCPU 
    TotalNumberOfCores 
    NumberOfLogicalCPUs

  • How to pass a variable for a SQL query in OLEDB source?

    Hi All,
    I am new to SSIS and working on it past few days. Can anyone please help me getting through a scenario where I need to pass a variable in the SQL statement in OLEDB source connection. Please find below for the details.
    eg:
    1) I have a SQL table with the columns SerialNumber, Name, IsValid, FileName with multiple rows.
    2) I have the file Name in a variable called Variable1.
    3) I want to read the data from my SQL table filtering based on the FileName (Variable1) within a data flow task and pull that data to the destination table.
    Question: In the data flow task, added source and destination DB connection with a script component in between to perform my validations. When trying to retrieve the data from source using the variable (i.e. SQL Query with variable), I am not able to add
    the query as the SQL statement box is disabled. How to filter the data based on the variable in the source DB ?
    Any help/suggestions would be of great help.
    Thanks,
    Sri

    Just to add with Vaibhav comment .
    SQL Command  : SQL query either with SQL variable or any condition  or simple Sql statement
    Like ;
    Select * from dimcustomer
    SQL Command using Varible :
    Sometimes we design our dynamic query in variable and directly use that variable name in oledb source.
    If you Sql query needs a condition based on SSIS variable .
    you can find a Example here :
    http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/01/17/ssis-replace-dynamic-sql-with-variables.aspx
    http://www.select-sql.com/mssql/how-to-use-a-variable-inside-sql-in-ssis-data-flow-tasks.html
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com

  • How to create a Folder using a SQL Query?

    Hi
    How can I create a Folder (eg. C:\MyNewFolder) using SQL Query?

    Hi,
    I added some code in order to get the result from the xp_cmdshell command
    This returns null if successfull, if an error occurs returns the error message. May be useful instead of getting an sql error
    Code Snippet
    declare @cmdpath nvarchar(60), @Location nvarchar(100), @message nvarchar(max)
    set @Location = N'C:\Temp\Temp5'
    set @cmdpath = 'MD '+ @Location
    Create table #result
    result nvarchar(255)
    insert into #result (result) exec master.dbo.xp_cmdshell @cmdpath
    select @message = ISNULL(@message + ' - ','') + result from #result where result is not null
    select @message
    drop table #result
    Eralper
    http://www.kodyaz.com

Maybe you are looking for

  • Issues With Deleting Printer Drivers

    I'm currently using an Epson Stylus Photo 1400, and when I went to Epson.com to try and download the software that checks the ink levels, does diagnostics, etc, I accidently downloaded their EasyPrint which basically strips down the settings availabl

  • Boot Camp - No Device Found - Late 2011 MBP

    Hello All, Recently i have attempted to boot camp my late 2011 macbook pro using a bootable Windows 7 Professional IMG File and a bootable Windows drive. Creating the Bootable Drive had no issues, though, while trying to install windows onto the part

  • CF slows down to a halt ... images not displaying

    My primary laptop on which I do all coding ... - less than 1 year old - Dell (cough) XPS M1730 - Windows XP (latest) - ColdFusion Ver 8, developer edition. - No other issues with laptop Also running - SQL 2000 - Synergy - Anti virus etc. changed Nort

  • How to analyze the extraction process for 2LIS_02_SCL both in R/3 & BW.

    Hi All, I have a problem here regarding the extraction process for the DataSource 2LIS_02_SCL. The values posted by date fields like Posting Date (0PSTNG_DATE) Schedule Line Delivery Date (0SCL_DELDAT) Statistics Date (0STAT_DATE) In BW are suspected

  • How to Launch a Document

    Hi All - Hope someone can help. I am creating a stand alone catalogue which has mainly been built using Director but with buttons and some animation created in Flash. I'm a complete novice to all this so please bear with me and apologies if I have po