Monday, January 17, 2011

Copy files by passing Variables in batch file.

For regular DBA activities, we should also be aware of some Windows commands as well.
We will be copying files from one location to another for which batch file would be easier way to do so without commiting mistakes.

Open notepad copy the below script and save it as a batch file (.BAT) extension.

@echo off
echo "Enter Source"
set /p source=
echo "Enter Destination"
set /p destination=
xcopy %Source% %destination%


run the batch file.

Also to extend this, if you want to copy only specific date of file or files that are new in any particular folder use

xcopy %Source% %destination% /D:00:01 by default its value is 1day older to the current date.
xcopy the command that is used to copy file.

Wednesday, January 12, 2011

Cannot create New Database Diagram?

Check the owner of the database and change it to 'sa' .
If you want to create or see database diagram, yes the owner of the database have to be 'sa'.

Cannot Rename Computer or Server ?

Tip from my at work dad :) , when I say work dad yes he is my BOSS.

If you have SQL installed on computer or on the server you cannot Rename it, because it is stored in the registries. And you cannot clean registires its going to mess up everyting.
Work Around is you have to unistall SQL and do the rename.

Monday, January 10, 2011

How to Clear drop down list of Recent Connection from SQL Server Management Studio ?

http://sqlserver-training.com/how-to-clear-recent-sql-server-connection-list-from-ssms/-

Most Recent User Server List in SSMS drop down menu is known as MRU list.
SQL Server 2005
  1. Make sure that the "SQL Server management studio" is not opened
  2. Go to "Run"
  3. Type this command "%APPDATA%\Microsoft\Microsoft SQL Server\90\Tools\Shell\" and click "OK". This will open up the folder where this list is stored.
  4. Now search for the file "mru.dat" and rename this file.
  5. After renaming, launch the SQL Server management studio and you will not see any of the most recently used servers in the list.
For SQL Server 2008
  1. Make sure that the "SQL Server management studio" is not opened
  2. Go to "Run"
  3. Type this command "%APPDATA%\Microsoft\Microsoft SQL Server\100\Tools\Shell\" and click "OK". This will open up the folder where this list is stored
  4. Now search for the file "SqlStudio.bin" and delete / rename this file.
  5. After deleting, launch the SQL Server management studio and you will not see any of the most recently used servers in the list.