Thursday, October 25, 2012

SQL Server - Server Level Rights

I'm sure this is old hat for many of you out there, but I'm hardly a full time DBA by any means.  So - I read back up in prep for setting up some Security Access Groupings at my new gig........

http://www.sqlservercentral.com/articles/Administration/sqlserversecurityfixedroles/1163/


Monday, October 22, 2012

Some MS Stack Integration Blog Starting Points...

http://blogs.msdn.com/b/mattm/

http://blogs.technet.com/b/wikininjas/archive/2012/05/13/technet-wiki-microsoft-integration-stack.aspx

Five tips for smooth upgrade to SSIS 2012...

http://msdn.microsoft.com/en-us/library/hh667275.aspx

Bulk Insert into Oracle utilizing SSIS




Optimized Bulk Loading of Data into Oracle
SQL Server Technical Article

Writer: Carla Sabotta, Debarchan Sarkar
Technical Reviewer: Matt Masson, Jason Howell

Published: 04/2012
Applies to: SQL Server 2005 (all editions), SQL Server 2008, SQL Server 2008 R2, and SQL Server 2012 (non-Enterprise and non-Developer editions)

Summary: SQL Server 2008 and SQL Server 2008 R2 (Enterprise and Developer editions) support bulk loading Oracle data using Integration Services packages with the Microsoft Connector for Oracle by Attunity. For SQL Server 2005 and the non-Enterprise and non-Developer editions of SQL Server 2008 and 2008 R2, there are alternatives for achieving optimal performance when loading Oracle data. This paper discusses these alternatives.
The Enterprise and Developer editions of SQL Server 2012 also support bulk loading Oracle data using Integration Services packages with the Microsoft Connector for Oracle by Attunity.

 



Copyright

This document is provided “as-is”. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it.
Some examples depicted herein are provided for illustration only and are fictitious.  No real association or connection is intended or should be inferred.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes.
© 2011 Microsoft. All rights reserved.




Contents




Introduction

SQL Server 2008, 2008 R2, and 2012 (Enterprise and Developer editions) support bulk loading Oracle data using Integration Services (SSIS) packages. The Microsoft Connector for Oracle by Attunity provides optimal performance through their high-speed connectors during the loading or unloading of data from Oracle. For more information, see Using the Microsoft Connector for Oracle by Attunity with SQL Server 2008 Integration Services (http://msdn.microsoft.com/en-us/library/ee470675(SQL.100).aspx).
SQL Server 2005 and the non-Enterprise and non-Developer editions of SQL Server 2008, 2008 R2, and 2012 don’t provide an out-of-the box option for bulk loading Oracle data.
·        The fast load options for the OLE DB destination aren’t available when you use the Oracle OLE DB provider for Oracle because the provider doesn’t implement the IRowsetFastLoad (http://msdn.microsoft.com/en-us/library/ms131708.aspx) interface.
In addition, the current design of SSIS is such that it makes the fast load options available only for the SQL providers. The options aren’t available for any other provider even if the provider implements the IRowsetFastLoad interface.

·        The Microsoft OLE DB Provider for Oracle is deprecated and not recommended to use against Oracle versions later than 8i.
http://support.microsoft.com/kb/244661

In SQL Server 2005 and the non-Enterprise and non-Developer editions of SQL Server 2008, 2008 R2, and 2012, the out-of-the box, SSIS components implement single row inserts to load data to Oracle. When you use single row inserts, the following issues may occur.
·        Long load times and poor performance
·        Data migration deadlines are not met
·        Timeout during the ETL process for large production databases (greater than 500 GB) with complex referential integrity
For these releases, there are alternatives for achieving optimal performance when loading Oracle data. This paper discusses these alternatives.

Alternatives for Optimized Loading and Unloading Oracle Data

The following are alternatives for optimizing the loading of Oracle data.
Alternative
SQL Server Versions
Customized Script component
SQL Server 2005 and the non-Enterprise and non-Developer editions of SQL Server 2008, 2008 R2, and 2012.
Third-party components
SQL Server 2005 and the non-Enterprise and non-Developer editions of SQL Server 2008 and 2008 R2.

Customized Script Component

In this solution, a Script component is configured as a destination. The component connects to Oracle using the OLE DB provider from Oracle (OraOLEDB) and bulk loads data to an Oracle database. The Script component performs the data load in about half the time that it would take to perform single row inserts using an OLE DB destination.
The provider is included in the Oracle Data Access Components (ODAC) that is available for download on the Oracle Data Access Components site (http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html). An Oracle online account is required to download the software.
Note: You can also configure the Script component to connect to Oracle using the ODP.Net provider from Oracle.
The System.Data.OleDb namespace (http://tinyurl.com/7zuffuf ) is used in the script, as shown in the Microsoft Visual Basic code example below. The namespace is the .NET Framework Data Provider for OLE DB.
The PreExecute (http://tinyurl.com/86e4exe) method is overridden to create the OleDbParameter objects for each of the input columns. The parameters are added to the OleDbCommand Object, to configure the parameterized command that the destination will use to insert the data. In the example, the input columns are CustomerID, TerritoryID, AccountNumber, and ModifiedDate. Then, the database transaction is started.
The AcquireConnections (http://tinyurl.com/7qkkqvq) method is overridden to return a System.Data.OleDb.OleDbConnection from the connection manager that connects to the Oracle database.
The ProcessInputRow  (http://tinyurl.com/8y7vnh5 ) method is overridden to process the data in each input row as it passes through.








To configure the Script component
  1. Add a data source to the package, such as an OLE DB Source. The data source should have fields that can be easily loaded into a target table. In this example, we’re using the Customer table in the AdventureWorks database as the data source, and selecting the CustomerID, TerritoryID, AccountNumber, and ModifiedDate input columns.
  2. Add a Script component and configure the component as a destination. Connect the component to the data source.
  3. Double-click the Script component to open the Script Transformation Editor.










4.     Click Connection Managers in the left-hand pane.
5.     Click Add, and then select <New connection> in the Connection Manager Field. The Add SSIS Connection Manager dialog box appears.
6.     In the Add SSIS Connection Manager dialog box, select ADO.NET in the Connection manager type area, and then click Add.
7.     In the Configure ADO.NET Connection Manager dialog box click New to create a new data connection for the connection manager.
8.     In the Connection Manager dialog box, click the arrow next to the Provider drop-down list.
9.     Expand the .Net Providers for OleDb folder, click Oracle Provider for OLE DB, and then click OK.  
10.  Click Test Connection to confirm the connection, and then click OK.
11.  In the Configure ADO.NET Connection Manager dialog box, click the data connection you’ve created, and then click OK.
12.  In the Script Transformation Editor, click Input Columns in the left-hand pane, and click the CustomerID, TerritoryID, AccountNumber, and ModifiedDate columns in the Available Input Columns box.
13.  Click Script in the left-hand pane.


14.  Confirm that the ScriptLanguage property value is Microsoft Visual Basic, and then Click Edit Script.

NOTE: In SQL Server 2008, the Design Script button was renamed to Edit Script and support was added for the Microsoft Visual C# programming language.

Add the following Visual Basic code.


Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports System.Data.OleDb
Imports System.Data.Common

<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
Public Class ScriptMain
    Inherits UserComponent

    Dim row_count As Int64
    Dim batch_size As Int64

    Dim connMgr As IDTSConnectionManager100
    Dim oledbconn As OleDbConnection
    Dim oledbtran As OleDbTransaction
    Dim oledbCmd As OleDbCommand
    Dim oledbParam As OleDbParameter

    Public Overrides Sub PreExecute()
        batch_size = 8 * 1024
        row_count = 0
        oledbCmd = New OleDbCommand("INSERT INTO Customer(CustomerID, TerritoryID, AccountNumber, ModifiedDate) VALUES(?, ?, ?, ?)", oledbconn)
        oledbParam = New OleDbParameter("@CustomerID", OleDbType.Integer, 7)
        oledbCmd.Parameters.Add(oledbParam)
        oledbParam = New OleDbParameter("@TerritoryID", OleDbType.Integer, 7)
        oledbCmd.Parameters.Add(oledbParam)
        oledbParam = New OleDbParameter("@AccountNumber", OleDbType.VarChar, 7)
        oledbCmd.Parameters.Add(oledbParam)
        oledbParam = New OleDbParameter("@ModifiedDate", OleDbType.Date, 7)
        oledbCmd.Parameters.Add(oledbParam)

        oledbtran = oledbconn.BeginTransaction()
        oledbCmd.Transaction = oledbtran
        MyBase.PreExecute()
    End Sub

    Public Overrides Sub AcquireConnections(ByVal Transaction As Object)
        connMgr = Me.Connections.Connection
        oledbconn = CType(connMgr.AcquireConnection(Nothing), OleDb.OleDbConnection)
    End Sub


    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        With oledbCmd
            .Parameters("@CustomerID").Value = Row.CustomerID
            .Parameters("@TerritoryID").Value = Row.TerritoryID
            .Parameters("@AccountNumber").Value = Row.AccountNumber
            .Parameters("@ModifiedDate").Value = Row.ModifiedDate
            .ExecuteNonQuery()
        End With

        row_count = row_count + 1
        If (row_count Mod batch_size) = 0 Then
            oledbtran.Commit()
            oledbtran = oledbconn.BeginTransaction()
            oledbCmd.Transaction = oledbtran
        End If
    End Sub

    Public Overrides Sub PostExecute()
        MyBase.PostExecute()
    End Sub

    Public Overrides Sub ReleaseConnections()
        MyBase.ReleaseConnections()
    End Sub
End Class
15.  Save your changes to the Script component.
The SSIS package now contains the custom script component, configured as a destination to bulk load data to the Oracle data source.
Note: The above script component connects to Oracle, but it can be used to connect to other third-party data sources such as Sybase and Informix. The only change that you need to make is to configure the connection manager to use the correct OLE DB providers available for Sybase and Informix.

Third-party Components

In addition to the Script component solution discussed in this paper, there are third-party components that you can use to achieve optimal performance when loading Oracle data. The following components work with both SQL Server 2005 and SQL Server 2008.
·        Oracle Destination and ODBC Destination components from CozyRoc. For more information, see the CozyRoc web site.
·        Oracle Bulk Loader SSIS Connector from Persistent. For more information, contact Persistent.
·        Progress DataDirect Connect and DataDirect Connect64 components from Progress DataDirect. For more information, see the DataDirect web site.

Conclusion

SQL Server 2008, 2008 R2, and 2012 (Enterprise and Developer editions) support bulk loading Oracle data using SSIS packages.
For other SQL Server versions and editions, the following are alternatives for optimizing the loading of Oracle data when using SSIS packages.
Alternative
SQL Server versions and editions
Script component bulk loads data to Oracle using the Oracle OLE DB provider from Oracle

SQL Server 2005 and the non-Enterprise and non-Developer editions of SQL Server 2008, 2008 R2, and 2012.
Third-party components that connect to Oracle, from CozyRoc, Persistent, and DataDirect

SQL Server 2005 and the non-Enterprise and non-Developer editions of SQL Server 2008 and 2008 R2.

For more information:
SQL Server 2012: Microsoft Connectors V2.0 for Oracle and Teradata (http://www.microsoft.com/en-us/download/details.aspx?id=29283)
SSIS and Netezza: Loading data using OLE DB Destination (http://www.rafael-salas.com/2010/06/ssis-and-netezza-loading-data-using-ole.html)

Did this paper help you? Please give us your feedback. Tell us on a scale of 1 (poor) to 5 (excellent), how would you rate this paper and why have you given it this rating? For example:
·        Are you rating it high due to having good examples, excellent screen shots, clear writing, or another reason?
·        Are you rating it low due to poor examples, fuzzy screen shots, or unclear writing?
This feedback will help us improve the quality of white papers we release.


The .Net Builder Pattern...


"When we have an application that need to create an object which has to be constructed using many different objects, we find our client code cluttered with the details of the various Part objects that needs to be assembled together to create the resulting object.
To illustrate on above point let us take an example of mobile phone manufacturing system. Lets assume that we have a system installed at one of the mobile phone vendors. Now the manufacturer may decide to create a phone based on parameters like Touchscreen, Operating System, Battery and Stylus. Now if we have the objects for all these parts then creation of product with any combination of above parts would lead to a very complex and unmanageable code in the client application i.e. the module that will decide what kind of phone needs to be built.
Builder pattern is meant to solve such problems. GoF defines Builder pattern as:
Separate the construction of a complex object from its representation so that the same construction process can create different representations."


http://www.codeproject.com/Articles/470476/Understanding-and-Implementing-Builder-Pattern-in


Windows 8 Install on VMWorkstation 8

I had some issues installing Windows 8 on VM Workstation 8 - at first I mounted the iso directly on the first Wizard screen - tried a few installs, just kept hanging.  Then I tried mounting the iso at a later step in the Configuration screen as described in these instructions.  Voila!

http://www.sysprobs.com/how-to-install-windows-8-consumer-preview-on-vmware-with-working-vmware-tools

Stephen Hawking on Viruses......

I think computer viruses should count as life.  I think it says something about human nautre that the only form of life we have created so far is purely destructive.  We've created life in our own image...

TED is an amazing resource of intelligent talks given by speakers about subjects across the board.  These are some of my favorites:

1)  http://www.ted.com/talks/eddie_obeng_smart_failure_for_a_fast_changing_world.html - "The world is changing much more rapidly than most people realize, says business educator Eddie Obeng -- and creative output cannot keep up. In this spirited talk, he highlights three important changes we should understand for better productivity, and calls for a stronger culture of “smart failure."

This video hit home for me being in the IT industry - the amount of change and influx of information has become quite overwhelming for me as an IT professional.  There are so many different frameworks these days for different layers of the application layer, open source, MS, Oracle, ETC.  Eddie talks about this influx of information and how at some point, the learning curve flattened below the amount of incoming information.  He presents the tips of the icebergs for new concepts in dealing with this influx of info in terms of business.  Great watch.

2)  http://www.ted.com/talks/kevin_slavin_how_algorithms_shape_our_world.html - This talk is amazing to me having done some work in the market industry.  Kevin describes how algorithms have started to dictate how we communicate as a culture, or rather, how algorithms have started to dictate how we lay down infrastructure for their own communication.  By far the majority of trading within the world's stock market are algorithmic in nature, this is something that should be analyzed - feared perhaps.

"Kevin Slavin argues that we're living in a world designed for -- and increasingly controlled by -- algorithms. In this riveting talk from TEDGlobal, he shows how these complex computer programs determine: espionage tactics, stock prices, movie scripts, and architecture. And he warns that we are writing code we can't understand, with implications we can't control."

3)  This video is amazing to me now that I have children - not only does Deb take a look at language development, the information gleaned from this research lends itself to some amazing thoughts outside of language development.  Think social media analysis combined with Big Data.

http://www.ted.com/talks/deb_roy_the_birth_of_a_word.html

"MIT researcher Deb Roy wanted to understand how his infant son learned language -- so he wired up his house with videocameras to catch every moment (with exceptions) of his son's life, then parsed 90,000 hours of home video to watch "gaaaa" slowly turn into "water." Astonishing, data-rich research with deep implications for how we learn."



Tuesday, October 16, 2012

Learned more about SCADA and ModBus today!  What are those you ask?  SCADA is used in the Oil/Gas world for Gas Measurement Data collection among other things.  ModBus is a technology / communication protocol utilized within SCADA to pass that data along to interested parties.  It was released in 1979.  I was two years of age hahah.

http://en.wikipedia.org/wiki/Modbus

http://en.wikipedia.org/wiki/SCADA

Testing. Test it. Test.

I am a large fan of two things - Testing and Test Driven Development.  I think it is time to slow it down out in the IT world and write GOOD code over OK code that gets the job done.  It might take a bit longer, but in the long run, time and money will be saved!!  There are numerous ways this can be accomplished IMHO both from a process standpoint (good SDLC methodology rigor) and also from an actual Development swinging the hammer cutting the wood standpoint.  Testing is equally as important to good development for long term maintenance.  A couple of articles along those lines:

http://net.tutsplus.com/tutorials/php/deciphering-testing-jargon/

http://blog.pluralsight.com/2012/10/15/tdd-is-there-really-any-debate-any-longer/

Time to grow up...


So I've reached the end of the first third of my career, man/woman upstairs willing.  It’s been a fly by the seat of my pants type of experience.  While I'll freely admit I consider myself rather successful, I also consider myself EXTREMELY lucky to have had many/most of those successes.  I've made a decision recently based on what I'd consider a blessing in disguise - being laid off.  That decision is to dedicate the next third of my career to not being lucky, but rather, being prepared.  The first step in that process is to begin the documentation process of everything I learn henceforth.  The second step is each day I will tackle a new job related subject/idea/web posting and will post about it.  I realize, there is 98 percent I do not know, perhaps 2 that I do.  This is an exercise in taking back control of that disproportionate number.  Learn on.  Learn on.