Professional Documents
Culture Documents
10) How to change DB from single user to multi user or multi user to single user?
13) How to know the database backup process like how much % completed and estimation time?
16) How to script out or script generation an entire DB like all the objects such as
tables, stored procedures and functions?
17) Patching?
GUI Method::
Go to particular DB security Right click on user new user select user type
Select user name select location as entire directory enter object name and check
connections ok --. Give login name select default schema like dbo.
2) How to take DB offline or online?
GUI Method::
Right click on particular Db Tasks select offline or online
GUI Method::
Right click on particular database Go to properties You can see only collation status in
General tab For changing collation you should go Options tab Select required collation
ok.
(OR)
T.SQL
Select particular database and click on new query and paste below script in new window and click
on execute button.
GUI Method::
Login to SSMS (This is mandatory step) Right click on the instance (server) name
Go to properties Security Server authentication select windows or mixed ok.
GUI Method::
5) Scripts execution?
Login to SSMS Select particular database and click on new query (one new window will open
paste that script in new window) click on execute button.
7) How to take backup and restoration?
For Backup ::
Select particular database name Right click on that database name Go to Tasks Backup
Select ADD button and select location path Give file name with extinction .BAK ok.
For Restoration ::
Select particular database name Right click on that database name Go to Tasks Select
restore button select add button select that required restoration backup file ok.
8) User creation?
GUI Method::
Login to SSMS go to security logins click on search name enter user name & check
name select locations as enter directory which means Active Directory ok
Look at server role select server role based on condition click user mapping select db
name where we want to select that particular user select default schema as dbo select
db role for that particular user ok.
GUI Method::
Launch SSMS and login In the object explorer pane, expand the management folder
Right click on Maintenance plans Select Maintenance plan wizard Click next Specify the
name for the plan select separate schedules for each task and then click next On the
select maintenance tasks page select the backup database (Full or Differential or Log) Next
Next Define full backup setting Select the database that you want to backup (like all
user databases or particular databases) Select backup media (like Disk or Tape) select
verify backup integrity check box In the job schedule properties select Recurring for the
schedule type Give schedules as per requirements ok .
10) How to change DB from single user to multi user or multi user to single user?
GUI Method:
Right click on particular database Go to Properties In Restrict Access select required
mode.
(OR)
T .SQL:
Alter database [give database name] set SINGLE_USER with rollback immediate;
Alter database [give database name] set MULTI_USER;
GUI Method:
Expand system databases Right click on TEMPDB go to properties
Just look at that size (both data and log file) and space available
Note: How to find out how much data file and log file holds the size in tempdb.
Right click on tempdb tasks shrink select file type data or log
Select file name (:: In production mostly more than 1 file)
Give shrink action type ok
Note: 10 desired size in MB, Keep in mind that size needs to be more than or equal to minimum
required size of tempdb, otherwise tempdb will not shrink.
Go
12) How to give granting permissions to users in sql server?
Login to SSMS Expand security Right click on logins New login Give login name in the
format of (Domain\username) in General Tab Select authentication Mode Select default
database as Master Go to Server Roles Select Public Go to User Mapping Select required
databases and default schema as dbo and then select database role membership 0k.
13) How to know the database backup process like how much % completed and estimation time?
When the database backup is in executing status (Not Completed) that time we should know how
much % completed and remaining estimation time like.......For this you can execute below script.
Select particular database and select new query in that new window paste below script and click on
execute button it will give the information about backup and restore.
GUI Method:
Go to particular Db Reports Standard reports All blocking transactions
From 2008 version onwards Go to Management Activity Monitor View processes
For killing blocking Go to Management Activity Monitor View processes Right
click on process ID Kill Process.
(OR)
T.SQL
Sp_who2 (:: It will give the information about the blockings you can find through blk column)
Note: Blocking are not database level these are application level.
2) Application Role
For Example: There are 4 tables in DB, but we want to give permissions to see only 2 tables from out of
4 tables that time we should give db role for those 2 tables for particular users.
1) DB Role:
Go to particular db Security Expand roles Create db role (If don’t have) Give role
name Select owner Go to securables Search that object ok Select object type
Go to browse button Select matching objects ok Give permissions for dbo
customer......... ok Double click on created db role add Browse Select required
users ok.
2) Application Role:
Here we can permissions to particular stored procedures, tables and functions etc.
16) How to script out or script generation an entire DB like all the objects such as tables, stored
procedures and functions?
::: This needs mostly in the time of Migration or Up gradation DB from one place (or server) to another
place.
Right click on particular DB Tasks Scripts an generated Next Select DB object type
Next Select output type Give the path in file name Next Next Finish.
:::: If customer needs to execute this in target place or in any another server.
Go to Target server Click on New query Open that saved script Change location path
for mdf and ldf file Execute.
17) Patching?
Link: http://sqlserverversions.blogspot.in/
Select appropriate version service pack Go to setup file Right click and run as
administrator Next Click the button I accept the licence terms Next Select
MSSQLSERVER or Next Next upgrade Next Finish or Close.
Note: Before going to install make conformation which service pack the server holds currently. For that
run below query.
Select @@version
Right click on particular db tasks Shrink Select or give required database name select file
type data or log or file stream select file group select shrink action
Note: If you want shrink log file in 2008, 2012, 2014 need to bring database into Simple recovery model
or take backup of that Transactional Log.