Click here to Skip to main content
15,890,897 members
Home / Discussions / Database
   

Database

 
AnswerRe: Merge Replication Problem Pin
Jay Royall23-Dec-09 1:59
Jay Royall23-Dec-09 1:59 
QuestionQuery Pin
sarang_k21-Dec-09 22:04
sarang_k21-Dec-09 22:04 
AnswerRe: Query Pin
Blue_Boy21-Dec-09 22:33
Blue_Boy21-Dec-09 22:33 
AnswerRe: Query Pin
Niladri_Biswas22-Dec-09 16:32
Niladri_Biswas22-Dec-09 16:32 
Questionerror in restore Pin
NarendraSinghJTV21-Dec-09 20:19
NarendraSinghJTV21-Dec-09 20:19 
AnswerRe: error in restore Pin
Ashfield21-Dec-09 23:10
Ashfield21-Dec-09 23:10 
GeneralRe: error in restore Pin
NarendraSinghJTV21-Dec-09 23:49
NarendraSinghJTV21-Dec-09 23:49 
GeneralRe: error in restore Pin
Vimalsoft(Pty) Ltd22-Dec-09 2:24
professionalVimalsoft(Pty) Ltd22-Dec-09 2:24 
i usually have to Sp that Closes the Connection before i do a Back or Restore.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[sp_ClearDatabaseConnections] 

@DBNAME VARCHAR(255)

AS

SET NOCOUNT ON

DECLARE @SPID INT, @STR VARCHAR(255)

DECLARE USERS CURSOR FOR
	SELECT SPID
	FROM MASTER..SYSPROCESSES
	WHERE DB_NAME(DBID) = @DBNAME

OPEN USERS
FETCH NEXT FROM USERS INTO @SPID

WHILE @@FETCH_STATUS <> -1
BEGIN
   IF @@FETCH_STATUS = 0
   BEGIN
      SET @STR = 'KILL ' + CONVERT(VARCHAR, @SPID)
      EXEC (@STR)
   END
   FETCH NEXT FROM USERS INTO @SPID
END

DEALLOCATE USERS 


as you can see it accept the name of the DB that you want to Restore.

Vuyiswa Maseko,

Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

GeneralRe: error in restore Pin
NarendraSinghJTV22-Dec-09 18:02
NarendraSinghJTV22-Dec-09 18:02 
GeneralRe: error in restore Pin
Vimalsoft(Pty) Ltd22-Dec-09 18:52
professionalVimalsoft(Pty) Ltd22-Dec-09 18:52 
Questionget encrypted passwords from sql using encryption string Pin
220821-Dec-09 17:21
220821-Dec-09 17:21 
AnswerRe: get encrypted passwords from sql using encryption string Pin
Jörgen Andersson21-Dec-09 21:19
professionalJörgen Andersson21-Dec-09 21:19 
Questionstored procedure for restore .bak file Pin
NarendraSinghJTV21-Dec-09 17:11
NarendraSinghJTV21-Dec-09 17:11 
AnswerRe: stored procedure for restore .bak file Pin
Vimalsoft(Pty) Ltd22-Dec-09 2:26
professionalVimalsoft(Pty) Ltd22-Dec-09 2:26 
QuestionHelp building Trigger for updating summary table [modified] Pin
MAW3021-Dec-09 11:29
MAW3021-Dec-09 11:29 
AnswerRe: Help building Trigger for updating summary table Pin
Mycroft Holmes21-Dec-09 23:56
professionalMycroft Holmes21-Dec-09 23:56 
Questiontransaction error Pin
ademsandeepreddy20-Dec-09 19:53
ademsandeepreddy20-Dec-09 19:53 
AnswerRe: transaction error Pin
Member 450194023-Dec-09 7:31
Member 450194023-Dec-09 7:31 
QuestionNeed help with creating dynamic SQL statement Pin
James Shao20-Dec-09 17:54
James Shao20-Dec-09 17:54 
AnswerRe: Need help with creating dynamic SQL statement Pin
Mycroft Holmes21-Dec-09 11:00
professionalMycroft Holmes21-Dec-09 11:00 
QuestionNeed help with DATEDIFF function Pin
James Shao20-Dec-09 17:29
James Shao20-Dec-09 17:29 
AnswerRe: Need help with DATEDIFF function Pin
Ashfield21-Dec-09 0:27
Ashfield21-Dec-09 0:27 
GeneralRe: Need help with DATEDIFF function Pin
James Shao21-Dec-09 13:33
James Shao21-Dec-09 13:33 
Questioncannot excute script Pin
#Jet19-Dec-09 16:17
#Jet19-Dec-09 16:17 
AnswerRe: cannot excute script Pin
Eddy Vluggen20-Dec-09 0:08
professionalEddy Vluggen20-Dec-09 0:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.