When we are connection to the SQL server instance or opening the new query window, SQL server assigns a unique identification number to each connection. It is the Server Process ID and commonly known as SPID.
SPID 1 to 50
is reserved for SQL Server internal processes, and the user process starts from
SPID 51.
We can get
the all active SPID using SP_WHO or SP_WHO 2 command.
This command is use to Ends a user process that is based on
the session ID.
Syntax
Kill <SPID>
This kill the particular session.
Example
Here both
Session ID 56 and 66 are connected. Now we are killing the session id 66 for
session ID 56 window. Running the kill command.
SPID : 66
killed successfully.
If we run
again we will get the below message
Below is the script to kill the all SPID for a database
DECLARE @str_sql NVARCHAR(1000), @db_name VARCHAR(100), @number_of_session_killed INT SET @db_name = 'AdventureWorks2019' + @db_name + '" database' SELECT @number_of_session_killed = Count(*) FROM master.dbo.sysprocesses WHERE Db_name(dbid) = @db_name AND dbid <> 0 AND spid <> @@spid -- Create the sql to kill the active database connections SET @str_sql = '' FROM master.dbo.sysprocesses WHERE Db_name(dbid) = @db_name AND dbid <> 0 AND spid <> @@spid EXEC (@str_sql) PRINT @str_sql PRINT 'END: Killed "' + Cast(@number_of_session_killed AS VARCHAR(4)) + '" active connections to the
"' + @db_name + '" database' go |
Running this script
We can't
kill our own process also shouldn't kill the following processes:
Ø AWAITING COMMAND
Ø CHECKPOINT SLEEP
Ø LAZY WRITER
Ø LOCK MONITOR
Ø SIGNAL HANDLER
KILL WITH STATUSONLY
This option tells SQL Server to terminate the specified process and
provide information about the termination status without actually terminating
the process. It's a way to check the status of the process before deciding
whether to proceed with termination.
Syntax
KILL SPID WITH STATUSONLY;
Running the command;
This gives
the information only. This is not terminating the SPID 58. Still it is in
active state. Let’s see.
Still
Session ID 58 is active.
Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man,Keep it up. Meanwhile visit our website for essay writing service |
ReplyDeleteessay writing help
essay writing services
essay writing help australia
online essay help
essay help online
essay help australia
essay services online
Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it.
ReplyDeleteThanks for sharing this information For more info, please connect Best Calendar Management Services in USA
ReplyDeleteAmazing blog, thanks for sharing. At a time when internet popularity is spreading at a rapid pace it's important that you use this platform for knowing about different things easily. Reporters as well as bloggers from different portals of the world are updating these blogs on a regular basis.
ReplyDeleteShah Rukh Khan Biography
Sha Rukh Khan Hot Images
Salman Khan Biography
Kareena Kapoor Biography
Parineeti Chopra Biography
Janhvi Kapoor Hot Images
Rajinikanth Biography
Anil Kapoor Biography
Saif Ali Khan Biography
Kriti Sanon Biography
Soloney Water
Celeb Guru
Deepika Padukone Biography
Karisma Kapoor Biography
Suniel Shetty Biography
Snake Tattoos
Moon Tattoos
Vidya Balan Biography
Alia Bhatt Biography
Sunny Leone Hot Images
Butterfly Tattoo
Dragon Tattoo
Aishwarya Rai Bachchan Biography
Tiger Shroff Hot Images
Nawazuddin Siddiqui Biography
Arshad Warsi Biography
Akshaye Khanna Biography
Jacqueline Fernandez Biography
Sonakshi Sinha Biography
Sonakshi Sinha Sexy Images Gallery
Jacqueline Fernandez Hot Images
Mein Drama Review
Sukoon Drama Review
Thanks for sharing. it is so helpful
ReplyDeleteQuality Thought
iHub Talent
I appreciate your clear explanations and the outstanding alignment of your content with your blog! I strongly recommend visiting the website below if you're interested in sharing your work.
ReplyDeletehttps://3zenx.com/performance-testing-training-in-hyderabad
Hi, I am new to your audience on your article, I would say that you are doing fantastic work, and this would be super useful.
ReplyDeleteLatest News
Thanks for sharing this information For more info, please connect Top RPO Companies In USA 2024
ReplyDeleteThanks for sharing this information For more info, please connect Best SEO Services in USA
ReplyDeleteI appreciate your kind words about the knowledge you provide and your openness to suggestions for enhancing my life and personal growth. One way to pursue this could involve exploring opportunities to improve your skills in Global Degrees After finishing 12th grade Global Degrees can help Indian students study abroad, offering them a chance for an amazing academic adventure. Global Degrees works with universities to create a supportive environment where students can do well in their studies and grow personally and culturally.
ReplyDeleteThank you for sharing useful information with us. please keep sharing like this. And if you are searching an ONLINE MBA DEGREE COURSE from Top Universities in India, Colleges discovery platform, which connects students or working professionals with Universities/colleges, at the same time offering information about colleges, courses, entrance exam details, admission notifications, scholarships, and all related topics. Please visit below links:
ReplyDeletehttps://onlinembadegree.in/
Amazing blog, thanks for sharing. At a time when internet popularity is spreading at a rapid pace it's important that you use this platform for knowing about different things easily. Reporters as well as bloggers from different portals of the world are updating these blogs on a regular basis.
ReplyDeleteclick here for more information
Thanks for sharing such a nice blog with us . keep updating please reach on https://overseasdropshipper.com/
ReplyDeleteThanks for sharing such a nice blog with us . keep updating please reach on https://overseasdropshipper.com/
ReplyDelete