What's up!

Pyaarey Allah!

Wednesday, April 1, 2015

Backup and Archive Sql Server Database

0 comments

-- Set the name of the archive backup directory.



DECLARE @bakdir VARCHAR(300)
SET @bakdir = 'D:\radmade_projects\src\code\_db\'

-- Set the name of the database.
DECLARE @dbname NVARCHAR(1024)
SET @dbname = 'rmMedia'

-- Set the name of the database backup directory.
DECLARE @dbbakdir VARCHAR(300)
SET @dbbakdir = @bakdir 

-- Create the name of the backup file from the database name and the current date.
DECLARE @bakname VARCHAR(300)
SET @bakname = @dbname + '_backup_' + REPLACE(CONVERT(VARCHAR(20), GETDATE(), 112) + CONVERT(VARCHAR(20), GETDATE(), 108),':','')

-- Set the name of the backup file.
DECLARE @filename VARCHAR(300)
SET @filename = @dbbakdir + '\' + @bakname+'.bak'

-- Create the directories if necessary.
EXECUTE master.dbo.xp_create_subdir @dbbakdir
EXECUTE master.dbo.xp_create_subdir @bakdir

-- Backup the database.
BACKUP DATABASE @dbname
TO  DISK = @filename
WITH NOFORMAT, NOINIT,  NAME = @bakname, SKIP, REWIND, NOUNLOAD,  STATS = 10


-- Turn on the 'xp_cmdshell' function.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE

-- Build the command line string to add the file to the ZIP archive.
DECLARE @cmd VARCHAR(300)
--set @cmd = '"C:\program files\7-zip\7z.exe" a -tzip "D:\radmade_projects\src\code\_db\rmMedia\db.zip"  "D:\radmade_projects\src\code\_db\rmMedia\db.bak"'
SET @cmd = 'cd.. && "C:\program files\7-zip\7z.exe" a -tzip "' + @bakdir + @bakname + '.zip" "' + @filename + '"'

-- Execute the command.
EXEC xp_cmdshell @cmd

SET @cmd = 'del "' + @filename + '"'

-- Execute the command.
EXEC xp_cmdshell @cmd

-- Turn off the 'xp_cmdshell' function.
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE
EXEC sp_configure 'show advanced options', 0
RECONFIGURE

GO

Thursday, March 12, 2015

Essential Concepts for a .NET Programmer

0 comments

C-Sharp(course-outline)
Basic Language features of C#
.Net Framework Introduction
T-Sql basic language features
Interface.
Classes.
Console Application.
Enumeration.
Properties.
Events.
Access modifiers.
Delegates.
Language-Features.
Generics.
Linq.
Extension Method.
Lamda Expression.
Anonymous Function & Type.
Collections.
Collection Intializers.
Collection-Dictionary.
Array List.
Parallel Programming
Threading.
Exception Handling
File Reading/Writing(SystemI/O).
System.String & String Operations.
System.Data.SqlClient(ADO.NET)
Reflection.
Send Email.
Download file from url.
Encryption/Decryption.
Entity Framework(5 or 6).
App.configg & web.Config basic & advanced techniques


MS SQL Server Installation
Create Table
Create Primary key.
Foreign key.
Index(cluster,non-cluster).
Create view.
Stored Procedure.
Cursor.
Trigger.
Normalization(3-Forms).
Data access from ado.net & Entity Framework. 

Good C# Tutorials on Pluralsite

0 comments

http://www.pluralsight.com/courses/csharp-from-scratch
 http://www.pluralsight.com/courses/csharp-from-scratch-part2
http://www.pluralsight.com/courses/csharp-fundamentals-csharp5
http://www.pluralsight.com/courses/csharp-generics
http://www.pluralsight.com/courses/csharp-interfaces
http://www.pluralsight.com/courses/csharp-collections
http://www.pluralsight.com/courses/csharp-extension-methods
http://www.pluralsight.com/courses/skeet-async
http://www.pluralsight.com/courses/csharp-events-delegates

Wednesday, March 5, 2014

SQL Server - Kill process attached to database

0 comments

If you are trying to run a command


And you can't get access to the database because database might be in use by the single user and is in the single user mode.

There is a work around.

Run This command


SP_Who will show you processes attached to your database. See DBNAME Column and find your database in it. Then note down SPID. For example 72 is the SPID of the process you want to kill.
Then run this command to kill the process.

Kill command will kill the process. And then you will be able to run Set multi user mode command again and it should work.

Saturday, February 8, 2014

Shrink database and check its progress

0 comments

Claiming space from a SQL Server database is not like deleting all rows from a table or truncate it. Please follow the instructions if you want to reclaim your disk space.

  1. Run Sql Command:
    DBCC SHRINKDATABASE (MyDBName, 10 )
    Here MyDBName is a valid database name and 10 is the percentage of reserved free space.
  2. Run following command to check percentage done:
    select percent_complete, total_elapsed_time, estimated_completion_time, * from sys.dm_exec_requests where command = 'DbccFilesCompact'

Monday, October 14, 2013

Husool ka pehla usool

0 comments

Husool ka pehla usool be-nyazi hai

Sunday, October 6, 2013

Got a new PC

0 comments

I got a new desktop PC with
Intel 4th Gen Processor Intel Core i7 4770-k 3.5GHZ
Asus Z87-Pro MotherBoard
2 x 8GB-1600 Corsair Memory sticks
2 x Samsung SSDs(540 mbps) Raid0 for Windows, 250GB Each
2 x 1TB WD Black Disks for critical data storage raid-1 SATA III
1 x 1TB WD SATA 1 for media files
CoolerMaster Casing
H100i Extreme performance Liquid Cooling unit
Ex 2 Extreme 650Watts Power Supply
Nvidia Gforce 650Ti Boost Graphics Card 2GB DDR5