The following job steps cannot be reached with the current job step flow logic in SSIS

Recently while scheduling our SSIS Packages in SQL Server Agent Jobs we got the below error

WARNING: The following job steps cannot be reached with the current job step flow logic:

[1] Fashion Spend package

We just need to make sure that we have set correct package in the Start Step properties in Job Properties Dialog Box

To: –

Hope it helps..

Advertisements

Using SQL Server Transactional Replication to move data from SQL Server (On-Prem) to Azure SQL

Hi,

Let us say we want to move data from Table named MyTable and view MyView from my SQL Server DB On-Prem to one of the Azure SQL Database.

The components involved here would be Publisher that publishes this data, Distributor that holds the information about the data to be published and Subscriber who subscribes to the data.

For Transaction Replication to work, the Azure SQL DB or any subscriber needs to have the matching schema as the published table. This can be achieved through Snapshot Agent which applies the snapshot. Distribution Agent distributes this snapshot to the Subscribers.

Transaction Replication Log Reader Agent looks for any changes in the published data. This agent runs at the distributor for “Push” subscriptions. It can run continuously and or can be scheduled. It looks for Insert, Update, Delete operations or any schema changes and pushes this to the Subscriptions.

Let us start by configuring the Distributor first. The distributor can be at the local or remote server.

We’d be creating a local Distributor here.

Right-click the Replication and select Configure Distribution

We are using the local server as Distributor.

Click Next.

Click Finish to complete the wizard.

This creates the distribution database in our Local Server.

Now let us configure the Publication.

Right-click the publication and select new publication. SampleDB is the DB from whose table and view we want to publish.

Select SampleDb

Select Transactional Publication

Select the table and the view

As we are publishing a view, we get the below message

We can click on Add to specify any filtering on the data to be published.

We can specify if we want to snapshot to be created immediately so that it is available while defining subscriptions. We can also schedule the Snapshot Agent or we can run it continuously.

Here we are specifying SQL Server Agent account.

Specify Publication Name and click on Finish to create the publication.

Now let us create the Subscription.

Right-click the publication created earlier, and select new Subscription

Select the publication

We can specify the type of subscriptions either Push or Pull. In our case, we are selecting Push.

Select Add SQL Server Subscriber to add our Azure SQL DB as the subscriber here.

Connect to the Azure SQL DB.

Here MyDB is the Azure DB to which we want to push the data.

Now specify the account for the Distribution Agent and to connect the Azure SQL DB.

Select Agent schedule as Run Continuously.

Click Finish to create the subscription.

Back in our Azure SQL DB, we can see the table and the view created with the data.

In Job Activity Monitor, we can see the details.

REPL-LogReader, REPL-Distribution and REBP-Snapshot.

Now just to test it, let us add 2 new rows in our Sample DB’s MyTable.

Back in our Azure DB, we can see the data being added to it.

More details below

https://www.pluralsight.com/courses/sqlserver-transactional-replication-fundamentals

https://docs.microsoft.com/en-us/sql/relational-databases/replication/publish/publish-data-and-database-objects

https://www.mssqltips.com/sqlservertip/5024/using-transactional-replication-with-an-azure-sql-database/

Hope it helps..

Displaying Image from File Attachment control in InfoPath form inside SSRS report.

I was assigned the task of displaying images attached to InfoPath form using file attachment control in one of the SQL Server Reporting Services Report.

For this we need to add an image control and set it’s property in the following manner

Image Source :- Database

Then select appropriate DataSet, Image Field and MimeType

Here to display the Image properly we need to write a Report Assembly with the following code.

public static class FileDecoder
    {
        /// <summary>
        /// Takes string value for image from the infopath form
        /// and converts it to proper bytes for displaying it as an image
        /// </summary>
        /// <param name="imageData">string representation of the image</param>
        /// <returns>corrected byte array</returns>
        public static byte[] GetCorrectedByte(string imageData)
        {
            byte[] attachmentNodeBytes = Convert.FromBase64String(imageData);
            // Position 20 contains a DWORD indicating the length of the
            // filename buffer. The filename is stored as Unicode so the
            // length is multiplied by 2.
            int fnLength = attachmentNodeBytes[20] * 2;
            // The file is located after the header, which is 24 bytes long
            // plus the length of the filename. 
            byte[] fileContents = new byte[attachmentNodeBytes.Length – (24 + fnLength)];

            for (int i = 0; i < fileContents.Length; ++i)
            {
                fileContents[i] = attachmentNodeBytes[24 + fnLength + i];
            }

            return fileContents;
        }

    }

 

And set the value for image control as

=(Namespace).FileDecoder.GetCorrectedByte(Fields!fieldName.Value)

ImageFromDB

 

Bye..

Using Left and CharIndex in Oracle

Well i was given the task to get the email id’s of the user which was stored in one of our oracle db table.

But the problem was that we wanted that part of emailid which  appears before ‘@’ .

Well coming from SQL Server background i thought it could be acheived using CharIndex and Left Function.

Let’s see what they do

Select Left(‘abcdef’,3)

-> abc

and

select charindex(‘c’,’abcde’)

-> 3

But than as expected there were no functions like charindex and left in Oracle.

After searching i finally managed to found the solution

Inplace of CharIndex we have instr function

select instr(‘ab’,’b’) from dual;

->2

and for left and also right we have

SUBSTR (`ABCDEF’,-5); //Right(..)

SUBSTR (`ABCDEF’,1,5); // Left(…

So finally the query was

substr(emailid,1,Instr(Emailid,’@’)-1)

-1 is used otherwise @ will also come along

And one more thing, to extract username portion from login name i.e  nishantr1 from

abccompany\nishantr1 we could write something as following

SUBSTRING(loginname ,charindex(‘\’,loginname)+1, len(loginname)) for sql server.


Bye