29.5.08

Migrating Data from multiple source to single destination

I have tried to migrate the data from multiple source to a single destination using SQL Server Integration Services. For migrating the data we have to create a new SSIS project inturn a new package will be created. Go to SSMS and create the below tables (TableA, TableB for source and TableC for destination)

Code Snippet
create table TableA(id int)
insert into TableA values(1)
insert into TableA values(2)
create table TableB(id int)
insert into TableB values(3)
create table TableC(id int)
select * from TableA
select * from TableB
Drag the Data flow task into Control flow package window.
Double clicking Data flow task we will get dataflow task window. Drag the OLEDB Source task.Double click OLEDB Source, you will get OLE DB Source editor. Set the OLE DB connection manager and select the table you want to migrate. Here we will select TableA. Click "Preview" button to check the
data.

Drag another OLEDB Source task.
Double click OLEDB Source task, you will get OLE DB Source editor. Set the OLE DB connection manager (connect to your server) and select the table you want to migrate. Here we will select TableB.Click "Preview" button to check the data.

Drag Union All task and double click this task, you will get Union All Transformation editor. Here you can map the output columns and input columns (You can change the input column as per your business functionality)

Drag OLE DB destination and double click it, you will get an editor.Select the destination database and table. Check the mappings located in the left side of the window. You can opt to keep the null values, identity values, whether you want the check the contraint and you can lock the table during data transfer. Click "Preview" button to check the existing data.
Now go to Control flow window and right click "Execute Task". Check the execution results window for the operations performed.
Check TableC data in SSMS.
Happy Learning!!!
Regards,
Venkatesan Prabu .J

Attended Microsoft Sessions

Last week on 23 -Thursday and 24-Friday. I've attended microsoft deep dive session on Visual studio 2008 and SQL Server 2008. Its really a good one.
Smitha, microsoft trainer have provided these two sessions. It's really good and i was amazed to see the new enhancements done in these recent versions.

Hats off to microsoft.
Regards,
Venkatesan prabu . J

Migrate SQL Server 2000 to SQL Server 2005 - Part 2

In order to work with SQL Server 2005 environment we have to set this option in our migrated database.
It’s used to govern the new features of SQL Server. Below is the screenshot showing the possible compatibility level of a particular database.
Right click the database - >Properties, you will get the below page,











Compatibility level for different version of SQL Server:
60 = SQL Server 6.0
65 = SQL Server 6.5
70 = SQL Server 7.0
80 = SQL Server 2000
90 = SQL Server 2005

Below is the query to retrieve the Compatibility level of the databases in our SQL Server.


Code Snippet
SELECT name, cmptlevel FROM master.dbo.sysdatabases

On executing the above query, below is the output.

If we want to update the update the compatibility level manually we can use the below query,

Code Snippet
EXEC sp_dbcmptlevel AdventureWorks, 80;

Problem Statement:
Consider am having a SQL Server 7.0 database and I have restored it into SQL Server 2005. Am having a stored procedure with *= used instead of left outer join. Similarly = * instead of right outer join. Is it possible for me to work my database as a SQL server 7.0 compatible one in SQL Server 2005 IDE (SSMS)
Solution:
Yes, it’s possible. We have to set the compatibility level of our SQL Server DB to 70
Code Snippet
EXEC sp_dbcmptlevel MyDatabase, 70;



Happy Learning!!!

Regards,

Venkatesan prabu. J

Migrating SQL Server 2000 to SQL Server 2005 - Part 1

In most of the projects, we used to work on migration work. In order to incorporate new features and advantages our application should be upgraded to support advanced software systems. SQL Server 2000 databases can be upgraded to newer version to support Database mirroring, Support to Ranking functions, Performance improvements and many more. During migration, we need to take backup of our existing SQL Server 2000 database and restore the same in SQL Server Management Studio.
1. Right click Databases -> Restore Database.









2. Click Restore Databases, you will be getting a restore window. Select the database name and specify the source for restore -> specify the *.bak file from your local drive by clicking “Add” button.


In some cases, we won’t have backup files. Instead, we will be having Database files as,
a. Master Database file (Primary) - MDF
b. Secondary Database file (Secondary) – NDF (Optional one)
c. Log Database file (Log File) – LDF

In this case, we have to detach these files from the existing SQL Server 2000 databases and attach the same using SSMS.
Right click Databases ->Attach -> Click Add button in the databases to attach and specify the mdf file location.








Now, you got your database right...
Happy Learning!!!
Regards,
Venkatesan prabu. J

7.5.08

Data Beyond Row Size limit

Problem:
SQL Server will allow a max row size of 8060 bytes. But, If i am having a table with column "Description" as Varchar(max). Since, Max keyword allows 2 GB of data. How my table row will react to store the data?
Solution:
The data will be stored as off-row values. It's stored upto a limit of 8060 bytes and this LOB will act as a root node with two child pointers,
1. One pointing to the data stored in 8060 bytes.
2. Other pointing to the location where the remaining datas are stored.
Happy Learning!!!
Regards,
Venkatesan Prabu . J

Compatibility Level in SQL Server

Compatibility Level:
It's used to govern the new features of sql server. It instructs the database to react accordinly. Consider am having a SQL Server 2000 database which is restored in SSMS(SQL Server Management Studio).
Right click the database properties and check the compatibility level in options tab, a drop down lists out different compatibility levels like,

Compatibility levels for different versions

70 = SQL Server 7.0
80 = SQL Server 2000
90 = SQL Server 2005
100 = SQL Server 2008

We can select among the options like, if we want legacy support for some queries or stored procedures we have to opt either Compatiblity level = 80 or 70.
Below is the query to retrieve the Compatibility Level of databases in a server,
SELECT name, cmptlevel FROM master.dbo.sysdatabases


It output resembles like,

Output
-----------------------
Name Cmptlevel
-----------------------
Master 90
MSDB 90
TempDB 90
Venkat 80
Model 90
------------------------


T-SQL Query to update the Compatibility level,
EXEC sp_dbcmptlevel AdventureWorks, 80;


Regards,
Venkatesan Prabu .J

1.5.08

My Photo