Thursday, September 20, 2012

NULL handling in String concatenation

            While concatenating varchar/char variable with other varchar/char variables,variable with null values assumed as empty space in sybase but not in SQL Server.In SQL Server any operations with null  results null.
            Sybase also provides the NULL result,while the integer manipulation using null value.I am giving the example to understand the scenario.
Sybase:
           SELECT @var1='Hi'
           SELECT @var2='I am'
           SELECT @var3=null
           SELECT @var1+@var2+@var3
Result:
  'Hi I am'
SQL Server:
          SELECT @var1='Hi'
          SELECT @var2='I am'
          SELECT @var3=null
          SELECT @var1+@var2+@var3
Result:
   NULL
           To avoid the data changes and maintain the integrity, we should handle the scenario.The statment should be like below.

SELECT @var1+@var2+ISNULL(@var3,'')
           For the above statement,we can get the same result of Sybase.

Please click here to know about sybase to sql server migration issues

Friday, September 14, 2012

Substring in Sybase and SQL Server

             Normally Sybase and SQL Server produces the same result for Substring() Function .But in some extends which produces the different results.
To Explain the substring behavior,i chosen four cases.
CASE 1:
         Declare @var varchar(30)='hi'         
         SELECT SUBSTRING(@var,start position = 0, length = 0)
Sybase result          =NULL
SQL Server result  =''
Both results are different.we need to handle this case.

CASE 2:
         Declare @var varchar(30)='hi'
         SELECT SUBSTRING(@var,start position=0, length = 1)
Sybase result          =NULL
SQL Server result  =''
Both results are different.we need to handle this case.

CASE 3:
         Declare @var varchar(30)='hi'
         SELECT SUBSTRING(@var,start position=1, length = 0)
Sybase result          =NULL
SQL Server result  =''
Both results are different.we need to handle this case.

CASE 4:
         Declare @var varchar(30)='hi'
         SELECT SUBSTRING(@var,start position=1, length = 1)
Sybase result          =h
SQL Server result  =h
Both results are same.We don't need to do any change.
If the starting position and legnth is more than 1,both the technologies will give the same results.
In that case we dont need to handle.
How to get Sybase result from SQL Server:
        To get the same result of Sybase, we should handle the first three cases.If we make the common code change like below,We can attain same result of Sybase.

         SELECT CASE WHEN SUBSTRING(@var,start position=0, length = 0)=''
                                   THEN NULL
                                   ELSE SELECT SUBSTRING(@var,start position=0, length = 0)
                        END
         By this code change,we can avoid the result of empty space ('').Using the SSMA generated  Sysdb Function,we can get the same result.Sample SSMA generated functions are given below.
SYSDB.SSMA_SYB.SUBSTRING_NVARCHAR(expression, start, length)
SYSDB.SSMA_SYB.SUBSTRING_VARCHAR(expression, start, length)

Please click here to know about sybase to sql server migration issues

Sunday, September 2, 2012

How to migrate sybase to sql server?

Sybase to MS SQL Server Migrarion:

               Migration from Sybase to MS SQL Server is easiest way,when compare with creating/developing new architecture.It's highly Technical Migration not a functional Migration.Technical experts able to migrate easily.
               There is lot of Tools available in the Market to reduce the human effort/time/cost .Some third party tools also available.I just provided some tools name here.

                1.Sybase to SQL Server Migration Assistance(SSMA) a Microsoft Product.
                2.SwisSQL a Third Party Product.           
                3.SQLWays a Third Party Product.

Microsoft only know very well about the Sybase and SQL Server Engines. And Microsoft recommending their native product SSMA.

The total Migration has two phases
               1.Phase 1-Migration using tool
               2.Phase 2-Manual conversion
          
               First phase of project,creates the all object in the SQL Server Database from the Sybase source database. Sybase to SQL Server Migration Tool helps you migrate Sybase ASE (Adaptive Server Enterprise) T-SQL Procedures, inbuilt functions, triggers, tables, views, and other database objects to Microsoft SQL Server T-SQL.SSMA is a first of its kind product with a productive migration environment that offers .

Different type of Object can migrate using SSMA.Object types given below.              


  • Stored Procedures

  • Triggers
  • Tables
  • Views
  • Indexes
  • User Defined Data types
  • User Defined Defaults
  • Datums.
  • etc

  •                Configuring SSMA is the mandatory process.To configure and migrate the Sybase database using tool,please click the link shown below.

    http://blogs.msdn.com/b/ssma/archive/2011/06/09/migrating-from-sybase-ase-to-sql-server-how-to-use-ssma-for-sybase.aspx

    Download SSMA


                   Second phase is completely developers activity.Which deals about transact sql changes.Developers should handle the SSMA shown Errors,SSMA shown warnings.
    Though the code has no errors/warnings  explicitly ,developers should concentrate some specific
    changes like cursor,null etc.If we miss the small changes,which leads to more time wastage in
    later point of time.I am here to share my knowledge/experience about all errors/warnings
    and required code changes i did in my last project.

                   You can find the detailed explanation of the errors/warnings and required changes from this blog.Please find the discussions in the further posts.

    Please click here to know about sybase to sql server migration issues