Jagadish's profileJagadish Pulakhandam'sPhotosBlogListsMore Tools Help

Blog


    April 24

    TIP: Copying rows from a DataView to a new DataTable

    In an ASP.NET app, I had a need to copy the data from a DataView to a DataTable for additional manipulation of the rows (without effecting the original table that the DataView was created on). Came across this:
     
    C# version (used conversion tool)
    ======================
    private DataTable DataViewAsDataTable(DataView dv) 
    {
            DataTable dt 
    dv.Table.Clone();
            foreach 
    (DataRowView dvr in dv)
           {
                dt.ImportRow(dvr.Row)
    ;
            
    }
            dt.AcceptChanges
    ;
            return 
    dt;
    }

    VB.NET version (used conversion tool)
    =========================
    Private Function DataViewAsDataTable(ByVal dv As DataView) As DataTable
            
    Dim dt As DataTable dv.Table.Clone
            
    For Each dvr As DataRowView In dv
                dt.ImportRow(dvr.Row)
            
    Next
            
    dt.AcceptChanges
            
    Return dt
    End Function
     
     
    April 12

    Northwind database scripts for Oracle

    "Northwind" is a demonstration database provided by Microsoft.  It is generally available with Access or SQL Server 2000.  I generated Oracle script for the same Northwind database (along with INSERT statements), to make it available as a demonstration database for Oracle as well. 
     
    You can find the scripts here:
     
     
    UPDATE:
     
     
    Note: 
    • Binary data is not scripted. 
    • Added a new field TerritoryID to "Orders" for better analytic queries.
    • I Generated the scripts with my own simple utility (developed in .NET).  The utility connects to SQL Server database and generates Oracle scripts.  You can get it for free (along with source code) by leaving your email in the comments.  Please be informed that I am giving some final touch-ups to the utility and it would take sometime to send you the utility. THE UTILITY IS NOT TUNED TO BE USED AT PRODUCTION LEVEL AND IT NEEDS TO BE THOROUGHLY TESTED.  IT CAN BE USED ONLY FOR LEARNING PURPOSES.  USE IT AT YOUR OWN RISK AND I WILL NOT BE RESPONSIBLE FOR ANY DAMAGE.

    Feedback is well appreciated and I will keep on updating the utility based on your feedback..

    thanks

    Jag

    April 02

    Part 3: More about CASE, @@ROWCOUNT and TABLES in T-SQL

    Hello,
     
    This is third in series focusing on the following topics:
     
    • A bit more concentration on CASE
    • CASE with IF
    • Utilizing @@ROWCOUNT
    • Working with TABLES (Table Variables) in T-SQL

    The article is available at http://www.aspfree.com/c/a/MS-SQL-Server/Using-ROWCOUNT-and-TABLE-Variables-for-Database-Interactions-with-TransactSQL/

    thanks

    Jag