how to add yourself to sysadmin role

April 9, 2013 1 comment

one of the best thing about attending SQL Saturday’s is the people you meet and tricks you learn .. (hmmm ok .. even the food included)

i come across similar webcast were i learned below 2 methods to add yourself  as sysadmin on any SQL instance ..

example : if the SQL installation was done by someone else and OS admins were never given sysadmins priviliges on SQL instance

so after you get yourself added to OS admin .. you can follow any of the below methods to achieve the same …

NOTE: both methods cause SQL restart .. so take a note of the same …

SQL Saturday 119 Lunch 017

SQL Saturday 119 Lunch 017 (Photo credit: Michael Kappel)

International Bibliography of Periodical Liter...

International Bibliography of Periodical Literature (Photo credit: Wikipedia)

 
Option 1: http://archive.msdn.microsoft.com/addselftosqlsysadmin/ (the logged in user gets added in sysadmin group)

download the cmd file from above link and save it onto the server .. where you want to add yourself to sysadmin ..

double click the cmd file and it will ask for instance name .. default is taken as the SQL express edition instance …

only enter the instance name (example for instance node-1\SQL2012_INST …. we will just enter SQL2012_INST .. not the network name)

below messages will appear in the cmd window .. (Note : it will cause SQL to restart as it puts instance in single-user mode and restarts it twice )

Adding ‘NODE-1\test’ to the ‘sysadmin’ role on SQL Server instance ‘SQL2012_INST
1’.
Verify the ‘MSSQL$SQL2012_INST1’ service exists …
Stop the ‘MSSQL$SQL2012_INST1’ service …
The SQL Server (SQL2012_INST1) service is stopping.
The SQL Server (SQL2012_INST1) service was stopped successfully.

Start the ‘MSSQL$SQL2012_INST1’ service in maintenance mode …
Add ‘NODE-1\test’ to the ‘sysadmin’ role …
Stop the ‘MSSQL$SQL2012_INST1’ service …
The SQL Server (SQL2012_INST1) service is stopping…
The SQL Server (SQL2012_INST1) service was stopped successfully.

The SQL Server (SQL2012_INST1) service is starting.
The SQL Server (SQL2012_INST1) service was started successfully.

‘NODE-1\test’ was successfully added to the ‘sysadmin’ role.
Press any key to continue . . .

Option: 2 http://sqlserver-help.com/2012/02/08/help-i-lost-sa-password-and-no-one-has-system-administrator-sysadmin-permission-what-should-i-do/

(you can explicitly choose which user/group is to be given sysadmin role, after you get yourself added in OS admin group)

Above is a manual method .. which has the same steps .. ie. Putting instance in single user and then adding a group or user to sysadmin role ..

enjoy 🙂

 

Categories: General, T-sql

Jack Lalanne Video

April 3, 2013 Leave a comment

Great stuff from Jack … Truth to be shared …

enjoy 🙂

Categories: LOA

Powershell Crash course part – 1

April 1, 2013 Leave a comment
Windows PowerShell exists?

Windows PowerShell exists? (Photo credit: crazytales562)

Hi All,

in this efforts , I will cover some PS basics to get myself and you started on Powershell..

Powershell helps DBA’s to achieve some complex functionality which are not possible by t-sql and command prompt

PS 1 had around 130 commands ,PS2 and PS3 have far more commands now

InstallingPS ..

PS wont get install on windows 2000 or older version then that ..

Newer OS like windows 7 and higher have Powershell preinstalled in that ..

for windows XP,windows 2003 etc go to http://www.microsoft.com/download to get your setup (check whether you need 32 or 64 bit)

to check whether PS is already available for your OS .. either enter powershell.exe in the START–> run prompt

OR go to add/remove program winmdows componets and add Powershell component ..

customizing the SHELL ..

you can right click on the edge of the prompt to customize the size of the window to suite ur preference …

getting Started :: (ur script may not run for that you have to set your execution policy to > set – executionpolicy unrestricted (refer this link for details PowerShell Basics – Execution Policy and Code Signing Part 1 (pauldotcom.com) ))

all the commands (also called as command-lets or cmdlets) in PS are in the form of VERB-noun form

even if the command returns multiple results the noun is singular ..

for example type get-process on the PS prompt (this will list all the process currently running on system )

PS D:\powershell\myscript> get-process

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
——- —— —– —– —– —— — ———–
194 4 3632 652 46 1.67 4140 AcroRd32
349 9 55876 29360 162 109.86 4700 AcroRd32
277 8 5296 712 61 5.59 3452 AdobeARM

below is my default prompt .. that i have set my powrshell to start in ..

PS D:\powershell\myscript> 

you will most probably start in in PS C:\document and setting\yourID >

to read the content of a file example text file use  :: get-content

PS D:powershell\myscript> get-content myfile.txt

all commandlets take parameters to acheive different funalities and parameters are positional … meaning you may skip typing parameter name if you passing the actual value of parameter

PS D:powershell\myscript> get-content myfile.txt

is same as PS D:powershell\myscript> get-content -path myfile.txt

where –path was the parameter

in PS if a articular path has a space in it use double quotes for it

PS D:powershell\myscript> get-content “C:\test files\myfile.txt”

ALIASES :: to make all administrators (*nix,cmd.exe) switch to PS an easier curve .. PS has all *nix working in PS too .. so you already many PS commands without knowing it 🙂

example :: cd ,dir,mkdir,del,ren,remdir will all work in PS without any issues ..

as all of them are aliases to PS under hood commands

PS D:powershell\myscript> get-alias  CD
CommandType Name Definition
———– —- ———-
Alias cd Set-Location

so CD is alias of PS command named SET-LOCATION

to get a list of all alias just type –> get-alias

creating a new alias (it will be available only in your session : to make it persistent you need to save it in ur profile )

PS D:powershell\myscript> new-alias N notepad

PS D:powershell\myscript> N 

above command will open up new notepad window .. you can create aliases of ur preferences ..

Thanks for reading .. will continue in part -2

SQL Server -g

March 5, 2013 1 comment
Categories: General

Simon Sinek …

February 23, 2013 Leave a comment

 

Great Thoughts from Simon Sinek …

on finding the why for all aspects of life

do watch

 

enjoy 🙂

 

Categories: General

get running job name from sysprocesses

February 20, 2013 1 comment
English: Labeled (SQL) database icon with shor...

English: Labeled (SQL) database icon with shortcut identification (Photo credit: Wikipedia)

Spid-1

Spid-1 (Photo credit: Eexlebots)

sometimes we need to find out the job details if multiple jobs are running at once and are involved in blocking or any other server performance issues …

the master..sysprocesses have column named program_name that represents the program from where a particular SPID is originating ..

for running SQL jobs this will be a hexadecimal string .. we can use below method to get the actual name of the job from sysjobs table

1> get the substring of the running job from sysprocess .. have filtered out generic refresher ETC

select substring(program_name,55,7) ‘to search’
from master..sysprocesses
where program_name like ‘%agent%’ and program_name not like ‘%DatabaseMail – SQLAGENT -%’
and program_name not in (‘SQLAgent – Alert Engine’,’SQLAgent – Generic Refresher’,’SQLAgent – Email Logger’,’SQLAgent – Job invocation engine’,’SQLAgent – Job Manager’)

output will be similar to below

Output :

to search
2FE3386
A68D437
3253286

Get the job details from MSDB database by using the results you got from above query and replace them in where clause

1>

select *
from msdb..sysjobs
where job_id like ‘%A68D437%’

OR

2> if you have more than one job running replace below job_id %strings%

select *
from msdb..sysjobs
where job_id like ‘%A68D437%’ or job_id like ‘%4E742EB%’ or job_id like ‘%FAEDF18%’

Enjoy 🙂

Categories: General, T-sql Tags: , ,

free SQL Training videos on plural sight

January 26, 2013 Leave a comment

 

Hi all …. get a free 24 hours training for any video on plural sight ..
(better to view first only the highly rated Videos under SQL or whatever you like )

1> like on twitter
2> submit your twitter handle
3> use the link and access code you receive on your twitter account to access all vidoes

http://blog.pluralsight.com/2013/01/17/see-what-everyones-talking-about-get-a-free-pluralsight-day-pass/

OR

http://pluralsight.com/training/TwitterOffer/seriesa

Categories: General Tags:

Powershell Alias

January 4, 2013 1 comment

Power shell is object oriented .. all commands or cmdlets .. return or take objects as parameters ..

to make switch from unix or *NIX easier .. to powershell most of the command have corresponding aliases in PS ..

example :

1> CLS – to clear screen

2>  DIR — to give list files and folders at current path/directory

3> to get all alias type at the PS prompt

get-ALIAS orPS1_1

get-alias cmdlet_name (to get alias for particular cmdlet)

4> to create a temporary alias of yourself

EG: set-ALIAS np notepad

once you have created alias .. if you just type np .. at the PS prompt .. it will open up Notepad

Categories: Powershell

Scripts to monitor SQL Server Memory usage in Buffer Pool, Plan Cache and identify Query Memory grants & waits by session

January 2, 2013 Leave a comment
Categories: memory, T-sql
Design a site like this with WordPress.com
Get started