How to migrate a SQL Server database to a lower version


Problem

After recently upgrading a SQL Server instance to SQL Server 2012 a few days ago, you noticed that your application is not functioning properly. You decided to roll back the upgrade by downgrading the SQL Server database engine to SQL Server 2008 R2.  After the downgrade of the database engine, you are unable to attach the databases or restore the backups of the databases, even though the database compatibility level is set to the downgraded version of SQL Server. You receive the following error message, when you attempt to restore the database:

Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘DatabaseName’. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database ‘DatabaseName’ cannot be opened because it is version 655. This server supports version 611 and earlier. A downgrade path is not supported.

This error message is generated because SQL Server automatically upgrades the database, when you restore or attach the database from lower version to higher version.  SQL Server does not allow you to restore or attach a database from a higher version of SQL Server to a lower version  of SQL Server. In this tip, we will look at a one time procedure which we can follow to downgrade the database from a higher version (SQL Server 2012) of SQL Server to a lower version (SQL Server 2008 R2) of SQL Server.

Solution

The error message in the problem statement occurs because the SQL Server database files (*.mdf, *.ndf and *.ldf) and backups are not backward compatible.  Backward compatibility is why we cannot restore or attach a database created from a higher version of SQL Server to a lower version SQL Server. However, there are a few options that can help us to downgrade the database from a higher version of SQL Server to a lower version SQL Server. These options include:

  • Generate Scripts wizard of SQL Server Management Studio
  • SQL Server Integration Services
  • Custom scripting and BCP

In this tip we will use the Generate Scripts wizard of SQL Server Management Studio.  Here are the basic steps we need to follow:

  • Script the database schema in higher version of SQL Server by using the Generate Scripts wizard of SQL Server Management Studio interface.
  • Connect to the lower version of SQL Server, and then run the SQL scripts that were generated in the previous step, to create database schema and copy data.

In the next section, I will demonstrate the steps for downgrading a SQL Server 2012 database to SQL Server 2008 R2 database.

Note: For demonstration purpose, I’ll be downgrading the OUTLANDER database hosted on my SQL Server 2012 instance (IITCUKDEV01) to SQL Server 2008 R2 instance (IITCUKSQLSERVER2008).

Step-by-Step Demo: Downgrading a SQL Server 2012 database to SQL Server 2008 R2

Step-1: Script the schema of the OUTLANDER database on the SQL Server 2012 instance (IITCUKDEV01) using the Generate Scripts wizard of the SQL Server Management Studio interface.

In Object Explorer connect to IITCUKDEV01, right-click OUTLANDER database, expand Tasks and choose “Generate Scripts…”.

In Object Explorer, right-click OUTLANDER database, expand Tasks and choose “Generate Scripts…”

This launches Generate and Publish Scripts wizard. Click Next, to skip the Introduction screen and proceed to the Choose Objects page.

SQL Server Management Generate and Publish Scripts Wizard - Introduction Screen

On the Choose Objects page, choose option “Script entire database and all database objects”, and then click Next to proceed to “Set Scripting Options” page.

Choose option Script entire database and all database objects in the SQL Server Management Studio Generate Scripts Wizard

On the Set Scripting Options page, specify the location where you want to save the script file, and then choose the Advanced button.

Choose option Specifying scripting options in the SQL Server Management Studio Generate Scripts Wizard

In Advanced Scripting Options dialog box, set Script Triggers, Indexes and Primary Key options to True, Script for Server Version to SQL Server 2008 R2, and Types of data to script to Schema and Data.  This last option is key because this is what generates the data per table.

Choose option Set scripting options including scripting the Schema and Data

Once done, click OK, to close Advanced Scripting Options dialog box and return to Set Scripting Options page. In Set Scripting Options page, click Next to continue to Summary page.

After reviewing your selections on Summary page, click Next to generate scripts.

Generate and Publish Scripts - Summary Interface

Once scripts are generated successfully, choose the Finish button to close the Generate and Publish Scripts wizard.

Generate and Publish Scripts wizard iterating through each object

Step-2: Connect to the SQL Server 2008 R2 instance (IITCUKSQLSERVER2008), and then run the SQL scripts that were generated in Step-1, to create the OUTLANDER database schema and copy its data.

In Object Explorer connect to IITCUKSQLServer2008, then in SQL Server Management Studio, open the SQL Server script you saved in Step-1.

SSMS
Opening SQL Script to install OUTLANDER database
Opening SQL Script to install OUTLANDER database

Modify the script, to specify the correct location for the OUTLANDER database data and log files. Once done, run the script to create the OUTLANDER database on IITCUKSQLServer2008 instance.

Restoring OUTLANDER database

Upon successful execution, refresh the Database folder in Object Explorer. As you can see in the following image OUTLANDER database has been successfully downgraded.

Verifying OUTLANDER database downgrade

Next Steps

  • To avoid this issue, always make sure that you perform a full backup of the database before you upgrade the SQL Server and database to a higher version of SQL Server.  In addition, be sure to thoroughly test the application prior to releasing the application to the users.
  • Consider this downgrade option as your last option to rollback from an upgrade because the time and storage needed can be very large.
  • With a very large database be sure you have sufficient storage to support the data needs.
  • Be sure to verify row and object counts as well as test your application before releas

HOW TO Setup Samba on Ubuntu[File sharing between Linux and windows]


1. Prerequisites

– Your Linux box should have an static ip-address.
In case you’re getting your ip from a router/server via DHCP make sure it’s configured to provide
a fixed dhcp-lease.

if that’s no valid option you cannot use WINS … more on this way down.

– You need to have samba installed.
If you haven’t done so already open a terminal and type:

sudo apt-get install samba

2. Getting samba configured
First, let us make sure samba isn’t running:

sudo /etc/init.d/samba stop

Since the installation of samba just installed a rather useless template file we’re going to rename it –
we keep the file just in case.

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.template

Next we create a new empty file

sudo touch /etc/samba/smb.conf

And finally we need to open the file inside an editor

sudo gedit /etc/samba/smb.conf

NOTE: If you’re on KDE replace “gedit” with “kate”

Copy / Paste the contents of the code-section below into your editor and read on …

{code section start}

[global]
; General server settings
netbios name = YOUR_HOSTNAME
server string =
workgroup = YOUR_WORKGROUP
announce version = 5.0
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192

passdb backend = tdbsam
security = user
null passwords = true
username map = /etc/samba/smbusers
name resolve order = hosts wins bcast

wins support = yes

printing = CUPS
printcap name = CUPS

syslog = 1
syslog only = yes

; NOTE: If you need access to the user home directories uncomment the
; lines below and adjust the settings to your hearts content.
;[homes]
;valid users = %S
;create mode = 0600
;directory mode = 0755
;browseable = no
;read only = no
;veto files = /*.{*}/.*/mail/bin/

; NOTE: Only needed if you run samba as a primary domain controller.
; Not needed as this config doesn’t cover that matter.
;[netlogon]
;path = /var/lib/samba/netlogon
;admin users = Administrator
;valid users = %U
;read only = no

; NOTE: Again – only needed if you’re running a primary domain controller.
;[Profiles]
;path = /var/lib/samba/profiles
;valid users = %U
;create mode = 0600
;directory mode = 0700
;writeable = yes
;browseable = no

; NOTE: Inside this place you may build a printer driver repository for
; Windows – I’ll cover this topic in another HOWTO.
[print$]
path = /var/lib/samba/printers
browseable = yes
guest ok = yes
read only = yes
write list = root
create mask = 0664
directory mask = 0775

[printers]
path = /tmp
printable = yes
guest ok = yes
browseable = no

; Uncomment if you need to share your CD-/DVD-ROM Drive
;[DVD-ROM Drive]
;path = /media/cdrom
;browseable = yes
;read only = yes
;guest ok = yes

[MyFiles]
path = /media/samba/
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
force user = YOUR_USERNAME
force group = YOUR_USERGROUP

{code section end}

Ok,Now there is a few simple things you may need to tweak; so here they are:
-> netbios name = YOUR_HOSTNAME Replace “YOUR_HOSTNAME” with your desired hostname (don’t use spaces!).
Best pratice would be to use the same name you configured upon installation.

Example:
netbios name = CRAZICODER
-> workgroup = YOUR_WORKGROUP Replace “YOUR_WORKGROUP” with the name of your workgroup,
but make sure you’re using the same as configured in Windows. To find out the Workgroup name in Windows
follow these steps:

– Click “START”
– Click “Control Panel”
– Click “System” – Click the 2nd Tab entitled “Computername” and find the name of the Workgroup there.

Example:
workgroup = MSHOME
-> wins support = yes
If your box doesn’t have a static ip-address, or you cannot configure your router/server to provide you with a
fixed dhcp-lease, change this configuration parameter to “no”. In this case you cannot use the benefits of WINS.

-> [MyFiles]

This is the name of the share. Leave it as it is or adjust it to whatever you prefer. Don’t use more than 31
characters and try to avoid spaces! -> path = /media/samba/ This suggests that you’ve mounted an hard drive or
partition on /media/samba where all the shared files will be stored. In case you don’t have an extra hard drive/partition
you may also create folder.I assume you’ve been wise enough to put /home onto a separate partition having an reasonable
amount of storage space. To create the folder type (inside a new terminal) …

sudo mkdir /home/samba

… and adjust “path =” to read … path = /home/samba/ Remember that this is just an
example – you are free to put things wherever you like.

-> force user = YOUR_USERNAME –
> force group = YOUR_USERNAME

Well, this should say it all. Replace “YOUR_USERNAME” with the name you use for login (no spaces!).

Example:
force user = crazicoder
force group = crazicoder
Now we completed the part of editing smb.conf Save the file and close gedit. Since we are going to share the folder
with other users we should now make sure that the permissions are set. Type:

sudo chmod 0777 /media/samba

NOTE: Don’t forget to correct the path to the location you chose above! That’s it – now we need to start samba.

1.1 Starting samba and setting up user accounts Let us fire up samba for the first time. Type:

sudo /etc/init.d/samba start

There shouldn’t be any errors – if you are presented with an error message make sure everything is correct
(search for typos and/or invalid paths). Time to add yourself as an samba user. NOTE: You will be asked for a password
– make sure you use the same as you use for login!

sudo smbpasswd -L -a your_username
sudo smbpasswd -L -e your_username

Now that we configured samba and created the user accounts we are done with the Linux-part – there’s one more thing to do
in Windows.

2. Changing network settings in Windows Now we should let Windows know that there’s a WINS server active in the network.
If you had to change “wins support” to “no” above skip this step!

– Click “START”
– Click “Control Panel”
– Click “Network Connections”
– Find your “LAN Connection”
– Right-click the icon and select “Properties”
– Select the “TCP/IP” Protocol and click the “Properties” button
– Click “Advanced” – Select the third Tab entitled “WINS”
– Click “Add” – Type in the ip-address of your Linux box
– Click “Add” – Select “Use NetBIOS over TCP/IP”
– Click “OK” – Click “OK”
– Click “OK”

– Reboot Windows Upon reboot you may now map the network drive within Windows.

With WINS enabled: –

Click “START”
– Right-click “My Computer”
– Select “Map network drive”
– Choose the drive letter
– Type \CRAZICODERMyFiles

NOTE: Adjust this to the hostname and sharename you chose above!

– Click “Finish”

With WINS disabled:

– Click “START”
– Right-click “My Computer”
– Select “Map network drive”
– Choose the drive letter
– Type \<ip-address>MyFiles

NOTE: To find out the ip-address of your Linux box type “ifconfig” inside a terminal and find the ip
for the correct interface (i.e. eth0). Don’t forget to adjust the sharename to the name you chose above.

– Click “Finish”
That’s it – samba is up and running now.

3. Security consideration This is the right time to think about security right away. In case your computer
has more than one network connection (i.e. wired and wireless ethernet) you may want to restrict access to samba.
If not especially configured samba will bind its service to all available network interfaces. So,
let us assume you only want your wired network to have access and that the network card is called eth0.
Add the following lines to the [general] section of your smb.conf to achieve that goal:

interfaces = lo, eth0
bind interfaces only = true

If you did it correctly it should look similar to this:

[CODE Start]
[global]
; General server settings
netbios name = YOUR_HOSTNAME
server string =
workgroup = YOUR_WORKGROUP
announce version = 5.0
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
interfaces = lo, eth0
bind interfaces only = true

[CODE End]

Now only the local loopback interface (dubbed “lo”) and eth0 are able to access samba – there’s no need to
fear that someone might break into your system by wireless as the interface isn’t bound to the service.

[Main Source]

তোমার চোখ এতো লাল কেন?


আমি বলছি না ভালোবাসতেই হবে, আমি চাই
কেউ একজন আমার জন্য অপেক্ষা করুক,
শুধু ঘরের ভেতর থেকে দরোজা খুলে দেবার জন্য।
বাইরে থেকে দরোজা খুলতে খুলতে আমি এখন ক্লান্ত।

আমি বলছি না ভালোবাসতেই হবে, আমি চাই
কেউ আমাকে খেতে দিক।
আমি হাতপাখা নিয়ে,
কাউকে আমার পাশে বসে থাকতে বলছি না,
আমি জানি, এই ইলেকট্রিকের যুগ
নারীকে মুক্তি দিয়েছে স্বামী-সেবার দায় থেকে।

আমি চাই কেউ একজন জিজ্ঞেস করুক:
আমার জল লাগবে কি না,
নুন লাগবে কি না,
পাটশাক ভাজার সঙ্গে আরও একটা
তেলে ভাজা শুকনো মরিচ লাগবে কি না।
এঁটো বাসন, গেঞ্জি-রুমাল আমি নিজেই ধুতে পারি।

আমি বলছি না ভলোবাসতেই হবে, আমি চাই
কেউ একজন ভিতর থেকে আমার ঘরের দরোজা খুলে দিক।
কেউ আমাকে কিছু খেতে বলুক।
কাম-বাসনার সঙ্গী না হোক,
কেউ অন্তত আমাকে জিজ্ঞেস করুক: “তোমার চোখ এতো লাল কেন?”

– নির্মলেন্দু গুণ

Ekushey Fonts for Ubuntu


I’ve been using the Unicode based Bengali fonts of Ekushey for a long time, specially SolaimanLipi which I use almost everywhere. To make these fine fonts easily available on Ubuntu, I’ve made a package of all of them called ttf-ekushey. Users of Ubuntu derivatives such as Linux Mint can use this package too.

Font list:

  1. SolaimanLipi
  2. Rupali
  3. Ekushey Lohit
  4. Ekushey Sharifa
  5. Ekushey Punarbhaba
  6. Ekushey Sumit
  7. Ekushey Durga
  8. Ekushey Saraswati
  9. Ekushey Puja
  10. Ekushey Azad
  11. Ekushey Godhuli
  12. Ekushey Mohua

(Twelve for now, but whenever they releases a new font I’ll update my package too.)

Ekushey Fonts for Ubuntu

Installation:

To install this package, you can either download the binary file (MD5: a6cbc1dae63c1cf62c1ff4ef4ab73068) from our Launchpad PPA, or install it via apt-get or your graphical package manager. This method is recommended, as you’ll get notification when an update is available. Here’s how to do it via apt-get:

1. Open the apt sources.list file from the run command dialogue box (ALT+F2):

gksudo gedit /etc/apt/sources.list (Ubuntu)

kdesudo kate /etc/apt/sources.list (Kubuntu)

gksudo mousepad /etc/apt/sources.list (Xubuntu)

2. Add the following line on the bottom of the file:

deb http://ppa.launchpad.net/ubuntu-bd/ubuntu intrepid main

3. Open a shell window and type:

sudo apt-get update

4. When the update is completed, type:

sudo apt-get install ttf-ekushey

When you see the warning message “The following packages cannot be authenticated!”, press y to continue.

5. Done, now you can use the Ekushey fonts on your system!

I’ll try to get this package into the Ubuntu repository, and possibly into the Debian repository as well.

Hope this is helpful to you guys.