-->
Здесь я публикую небольшие мои заметки, а также интересные ссылки, все что связанно с моей профессией. Для перехода на персональный сайт, используйте ссылку http://k-semenenko.blogspot.com

суббота, 23 октября 2010 г.

SQL SERVER – Taking Multiple Backup of Database in Single Command – Mirrored Database Backup

SQL SERVER – Taking Multiple Backup of Database in Single Command – Mirrored Database Backup: "

I recently had a very interesting experience. In one of my recent consultancy works, I was told by our client that they are going to take the backup of the database and will also a copy of it at the same time. I expressed that it was surely possible if they were going to use a mirror command. In addition, they told me that whenever they take two copies of the database, the size of the database, is always reduced. Now this was something not clear to me, I said it was not possible and so I asked them to show me the script.


Here was their script:


BACKUP DATABASE [AdventureWorks] TO

DISK =
N'D:\AdventureWorks.bak'

, DISK = N'E:\AdventureWorks.bak'

WITH FORMAT, INIT,

NAME = N'AdventureWorks-Full Database Backup'

GO


This script was very interesting to me. There is nothing wrong with it; however it does not duplicate your data. In fact, it splits your backup file in two parts and, when you restore, you will need both of these files. This was the reason why the size of the backup file was reduced whenever they took a backup on two places.


What they really needed was the following script wherein the full backup would be mirrored to another backup location:


BACKUP DATABASE [AdventureWorks] TO

DISK =
N'D:\AdventureWorks.bak'

MIRROR TO DISK = N'E:\AdventureWorks.bak'

WITH FORMAT, INIT,

NAME = N'AdventureWorks-Full Database Backup'

GO


In this case, when you check the size of the backup, you will notice that its size is not reduced as well.


I have previously written on this subject in very much detail. Here is the in-depth article about the same topic:


SQL SERVER – Mirrored Backup and Restore and Split File Backup


Do you use this MIRROR TO command in your production environment?


Reference : Pinal Dave (http://blog.sqlauthority.com)



Filed under: Pinal Dave, SQL, SQL Authority, SQL Backup and Restore, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology "

пятница, 22 октября 2010 г.

SQL SERVER – World Shapefile Download and Upload to Database – Spatial Database

SQL SERVER – World Shapefile Download and Upload to Database – Spatial Database: "

During my recent, training I was asked by a student if I know a place where he can download spatial files for all the countries around the world, as well as if there is a way to upload shape files to a database. Here is a quick tutorial for it.


VDS Technologies has all the spatial files for every location for free. You can download the spatial file from here. If you cannot find the spatial file you are looking for, please leave a comment here, and I will send you the necessary details. Unzip the file to a folder and it will have the following content.



Then, download Shape2SQL tool from SharpGIS. This is one of the best tools available to convert shapefiles to SQL tables. Afterwards, run the .exe file.


When the file is run for the first time, it will ask for the database properties. Provide your database details.



Select the appropriate shape files and the tool will fill up the essential details automatically. If you do not want to create the index on the column, uncheck the box beside it. The screenshot below is simply explains the procedure. You also have to be careful regarding your data, whether that is GEOMETRY or GEOGRAPHY. In this example,  it is GEOMETRY data.


Click “Upload to Database”. It will show you the uploading process. Once the shape file is uploaded, close the application and open SQL Server Management Studio (SSMS).




Run the following code in SSMS Query Editor.


USE Spatial

GO

SELECT *

FROM dbo.world

GO


This will show the complete map of world after you click on Spatial Results in Spatial Tab.




In Spatial Results Set, the Zoom feature is available. From the Select label column, choose the country name in order to show the country name overlaying the country borders.



Let me know if this tutorial is helpful enough. I am planning to write a few more posts about this later.


Note: Please note that the images displayed here do not reflect the original political boundaries. These data are pretty old and can probably draw incorrect maps as well. I have personally spotted several parts of the map where some countries are located a little bit inaccurately.


Reference : Pinal Dave (http://blog.SQLAuthority.com)



Filed under: Pinal Dave, SQL, SQL Add-On, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Spatial, SQL Tips and Tricks, SQL Utility, T SQL, Technology "

Investigating Transactions Using Dynamic Management Objects

very good article about transactions in SQL Server

http://www.simple-talk.com/sql/database-administration/investigating-transactions-using-dynamic-management-objects/