When I initialized and started the snapshot agent, how can I move the table
schema along with all the foreign keys? The only way I can think of is add
the script for before and after the initialization.
Does that mean the Replication not support repicate the foreign keys?
If I have the foreign keys in each replicated table, is the transacational
replication smart enough to insert data into into the parent table first?
Thanks
Ed
Hi Ed,
You can replicate fks with the initial snapshot for transactional
replication from SQL2000 onwards by enabling the 0x200 (DriForiegnKeys)
article schema option. There are, however a few things you need to watch out
for:
1) Support on SQL2000 is admittedly a bit glitchy, this is especially the
case if you use concurrent snapshot, have circular references (including
self-referencing fk), or you have fks referencing from outside the
publication.
2) Even though transactional replication is suposed to replay what happened
at the publisher in the same order, an update on the primary key is
typically translated into deletes followed by inserts. This can lead to
temporary violation of fks referencing the pk and the only way to workaround
this is to make sure that your fks at the subcriber has the "NOT FOR
REPLICATION" (NFR) property on them. SQL2005 makes this easier by providing
a schema option to mark all replicated fks NFR when they are replicated to
the subscriber.
-Raymond
"Ed" <Ed@.discussions.microsoft.com> wrote in message
news:83EE4199-8A99-4673-B999-CBF3C9151B78@.microsoft.com...
> When I initialized and started the snapshot agent, how can I move the
> table
> schema along with all the foreign keys? The only way I can think of is
> add
> the script for before and after the initialization.
> Does that mean the Replication not support repicate the foreign keys?
> If I have the foreign keys in each replicated table, is the transacational
> replication smart enough to insert data into into the parent table first?
> Thanks
> Ed
|||In SQL 05, there is an option if I want to replicate the foreign keys. Do I
still have to include all table Dependencies? Replication is smart enough to
know which table/foreign key needs to be created first?
The reason why i ask the question is I have a Prod and a Dev Server.
Developers always ask me to transfer all tables only to the Dev Server. I am
thinking using snapshot / transactional replication to update tables/data for
them.
That's why I would like to make sure moving the tables along with the
foreign keys is good and the replication knows the sequence of creating the
keys.
Thanks
"Raymond Mak [MSFT]" wrote:
> Hi Ed,
> You can replicate fks with the initial snapshot for transactional
> replication from SQL2000 onwards by enabling the 0x200 (DriForiegnKeys)
> article schema option. There are, however a few things you need to watch out
> for:
> 1) Support on SQL2000 is admittedly a bit glitchy, this is especially the
> case if you use concurrent snapshot, have circular references (including
> self-referencing fk), or you have fks referencing from outside the
> publication.
> 2) Even though transactional replication is suposed to replay what happened
> at the publisher in the same order, an update on the primary key is
> typically translated into deletes followed by inserts. This can lead to
> temporary violation of fks referencing the pk and the only way to workaround
> this is to make sure that your fks at the subcriber has the "NOT FOR
> REPLICATION" (NFR) property on them. SQL2005 makes this easier by providing
> a schema option to mark all replicated fks NFR when they are replicated to
> the subscriber.
> -Raymond
> "Ed" <Ed@.discussions.microsoft.com> wrote in message
> news:83EE4199-8A99-4673-B999-CBF3C9151B78@.microsoft.com...
>
>
|||You don't need to include all objects referenced by fks in your publication,
and the fks should be created in the right order (they only have to be
created after the unique\primary keys that they reference). The snapshot
agent history will tell you which fks cannot be replicated because they
reference something not in the publication.
-Raymond
"Ed" <Ed@.discussions.microsoft.com> wrote in message
news:3651674B-3142-462D-BD65-FE3D911591F7@.microsoft.com...[vbcol=seagreen]
> In SQL 05, there is an option if I want to replicate the foreign keys. Do
> I
> still have to include all table Dependencies? Replication is smart enough
> to
> know which table/foreign key needs to be created first?
> The reason why i ask the question is I have a Prod and a Dev Server.
> Developers always ask me to transfer all tables only to the Dev Server. I
> am
> thinking using snapshot / transactional replication to update tables/data
> for
> them.
> That's why I would like to make sure moving the tables along with the
> foreign keys is good and the replication knows the sequence of creating
> the
> keys.
> Thanks
> "Raymond Mak [MSFT]" wrote:
|||Thanks.
While I am playing with the table "Customers" and "Orders" in Northwind
database in SQL 2000, when I checked on "Include declared referential
integrity", the foreign keys still not get copied. Am I missing something?
Ed
"Raymond Mak [MSFT]" wrote:
> You don't need to include all objects referenced by fks in your publication,
> and the fks should be created in the right order (they only have to be
> created after the unique\primary keys that they reference). The snapshot
> agent history will tell you which fks cannot be replicated because they
> reference something not in the publication.
> -Raymond
> "Ed" <Ed@.discussions.microsoft.com> wrote in message
> news:3651674B-3142-462D-BD65-FE3D911591F7@.microsoft.com...
>
>
|||The Orders table in the Northwind database has FKs referencing the Employees
table and the Shippers table as well. In SQL2000, the snapshot agent will
simply not script any foreign key constraints from the referencing table if
*any* of the referenced tables is not part of the publication. The SQL2005
snapshot agent implements a much more granular approach of analyzing each
individual foreign key so the foreign key from Orders to Customers will be
replicated with the SQL2005 snapshot agent despite the fact that you didn't
include Employees and Shippers in your publication (you will even see in the
snapshot history messages why the FKs referencing Employees and Shippers are
not scripted). Ed, I got exactly the same question (down to the same tables)
from one of our support engineers just two days ago, did you contact
Microsoft Support for this?
-Raymond
"Ed" <Ed@.discussions.microsoft.com> wrote in message
news:190B9FF0-EC95-45A1-9B7A-6D6C3713D32F@.microsoft.com...[vbcol=seagreen]
> Thanks.
> While I am playing with the table "Customers" and "Orders" in Northwind
> database in SQL 2000, when I checked on "Include declared referential
> integrity", the foreign keys still not get copied. Am I missing
> something?
> Ed
> "Raymond Mak [MSFT]" wrote:
|||It was not me but I will play with SQL 05 to see the result.
Thanks again.
"Raymond Mak [MSFT]" wrote:
> The Orders table in the Northwind database has FKs referencing the Employees
> table and the Shippers table as well. In SQL2000, the snapshot agent will
> simply not script any foreign key constraints from the referencing table if
> *any* of the referenced tables is not part of the publication. The SQL2005
> snapshot agent implements a much more granular approach of analyzing each
> individual foreign key so the foreign key from Orders to Customers will be
> replicated with the SQL2005 snapshot agent despite the fact that you didn't
> include Employees and Shippers in your publication (you will even see in the
> snapshot history messages why the FKs referencing Employees and Shippers are
> not scripted). Ed, I got exactly the same question (down to the same tables)
> from one of our support engineers just two days ago, did you contact
> Microsoft Support for this?
> -Raymond
> "Ed" <Ed@.discussions.microsoft.com> wrote in message
> news:190B9FF0-EC95-45A1-9B7A-6D6C3713D32F@.microsoft.com...
>
>
Showing posts with label agent. Show all posts
Showing posts with label agent. Show all posts
Thursday, March 29, 2012
Foreign in Snapshot Replication
Labels:
agent,
along,
database,
foreign,
initialized,
keys,
microsoft,
mysql,
oracle,
replication,
server,
snapshot,
sql,
tableschema
Friday, March 23, 2012
Forcing a package to run as 32 bit on a x64 machine using SQL Server Agent?
I have a need to force a package to run using the 32-bit runtime from the SQL Server Agent. The machine is a x64 unit. I'm having to use an ODBC driver to extract data from our ERP package that will only run in 32 bit. Any help would be appreciated.
Hi.
Here is another suggestion: run distributed queries through SqlExpress/32. Here is a sample for MS Access:
http://gorm-braarvig.blogspot.com/2005/11/access-database-from-sql-200564.html
Hope this helps
|||In Agent, use an Operating System (CmdExec) step and use the copy of dtexec.exe in C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn
hth
Donald Farmer
|||Thanks, Donald. That worked like a charm.sql-ForceConvergenceLevel - Where dose it go?
It is (slightly) documented in BOL - see Replication
Merge Agent Utility. This is a commandline parameter that
can be added to the merge agent's job step. Is this
something that you have been told to do by PSS? I'm
curious about why you are implementing it.
Rgds,
Paul Ibison
[vbcol=seagreen]
Hi Paul.
I'm desperate, due to problems with rows not being replicated. Two
subscribers synchronizes fine without errors, but one gest all the rows from
a table and the other gets most but a few is missing. No filters is applied
on that article.
So I saw a discussion on the subject (can't remember where) and this article
http://support.microsoft.com/default...b;en-us;272210 so I thought
it was worth a try.
"Paul Ibison" wrote:
> It is (slightly) documented in BOL - see Replication
> Merge Agent Utility. This is a commandline parameter that
> can be added to the merge agent's job step. Is this
> something that you have been told to do by PSS? I'm
> curious about why you are implementing it.
> Rgds,
> Paul Ibison
>
>
Merge Agent Utility. This is a commandline parameter that
can be added to the merge agent's job step. Is this
something that you have been told to do by PSS? I'm
curious about why you are implementing it.
Rgds,
Paul Ibison
[vbcol=seagreen]
Hi Paul.
I'm desperate, due to problems with rows not being replicated. Two
subscribers synchronizes fine without errors, but one gest all the rows from
a table and the other gets most but a few is missing. No filters is applied
on that article.
So I saw a discussion on the subject (can't remember where) and this article
http://support.microsoft.com/default...b;en-us;272210 so I thought
it was worth a try.
"Paul Ibison" wrote:
> It is (slightly) documented in BOL - see Replication
> Merge Agent Utility. This is a commandline parameter that
> can be added to the merge agent's job step. Is this
> something that you have been told to do by PSS? I'm
> curious about why you are implementing it.
> Rgds,
> Paul Ibison
>
>
Labels:
agent,
agents,
bol,
commandline,
database,
documented,
forceconvergencelevel,
merge,
microsoft,
mysql,
oracle,
parameter,
replicationmerge,
server,
slightly,
sql,
thatcan,
utility
-ForceConvergenceLevel - Where dose it go?
Hi,
There is a undocumented Merge Agent parameter (-ForceConvergenceLevel) that
could solve some of my troubles, but where do I specify it?
It's not available in the the profile setup for the agent in the Enterprise
manager.
It's possible to specify it on the command line to replmerg.exe, but I want
it to be effektive whenever my subscribers synchronizes.
Regards
Jorgen D:
check this link out:
http://support.microsoft.com/default...b;en-us;305039
to use this expand replication monitor, expand the agents folder, expand the
merge agents folder, right click on your merge agent, select merge agent
properties, select steps, double click on Run Agent.
Click on the commands text box, press the end key, press the space key, and
enter -ForceConvergenceLevel and then the level you wish.
Then click apply, ok, apply, ok. Then right click again on your merge agent
and start it up.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"JorgenD" <JorgenD@.discussions.microsoft.com> wrote in message
news:ED4B5EE0-8FFD-40D1-8C44-FA295EAB3EFB@.microsoft.com...
> Hi,
> There is a undocumented Merge Agent parameter (-ForceConvergenceLevel)
that
> could solve some of my troubles, but where do I specify it?
> It's not available in the the profile setup for the agent in the
Enterprise
> manager.
> It's possible to specify it on the command line to replmerg.exe, but I
want
> it to be effektive whenever my subscribers synchronizes.
> Regards
> Jorgen D:
>
|||Thanks for your reply Hilary,
The problem is that my subscribers are anonymous and disconnected (SQL CE on
PDAs), so first of all I have 100+ merge agents and second, properties are
not available since they are not connected. Clicking Properties returns a
"SQL server not found"-error
When the subscriber connects and starts the merge process (pull
subsctiption) somhow the agent wakes up. But where is that "trigger"/"command
line"?
"Hilary Cotter" wrote:
> check this link out:
> http://support.microsoft.com/default...b;en-us;305039
> to use this expand replication monitor, expand the agents folder, expand the
> merge agents folder, right click on your merge agent, select merge agent
> properties, select steps, double click on Run Agent.
> Click on the commands text box, press the end key, press the space key, and
> enter -ForceConvergenceLevel and then the level you wish.
> Then click apply, ok, apply, ok. Then right click again on your merge agent
> and start it up.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
>
> "JorgenD" <JorgenD@.discussions.microsoft.com> wrote in message
> news:ED4B5EE0-8FFD-40D1-8C44-FA295EAB3EFB@.microsoft.com...
> that
> Enterprise
> want
>
>
There is a undocumented Merge Agent parameter (-ForceConvergenceLevel) that
could solve some of my troubles, but where do I specify it?
It's not available in the the profile setup for the agent in the Enterprise
manager.
It's possible to specify it on the command line to replmerg.exe, but I want
it to be effektive whenever my subscribers synchronizes.
Regards
Jorgen D:
check this link out:
http://support.microsoft.com/default...b;en-us;305039
to use this expand replication monitor, expand the agents folder, expand the
merge agents folder, right click on your merge agent, select merge agent
properties, select steps, double click on Run Agent.
Click on the commands text box, press the end key, press the space key, and
enter -ForceConvergenceLevel and then the level you wish.
Then click apply, ok, apply, ok. Then right click again on your merge agent
and start it up.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"JorgenD" <JorgenD@.discussions.microsoft.com> wrote in message
news:ED4B5EE0-8FFD-40D1-8C44-FA295EAB3EFB@.microsoft.com...
> Hi,
> There is a undocumented Merge Agent parameter (-ForceConvergenceLevel)
that
> could solve some of my troubles, but where do I specify it?
> It's not available in the the profile setup for the agent in the
Enterprise
> manager.
> It's possible to specify it on the command line to replmerg.exe, but I
want
> it to be effektive whenever my subscribers synchronizes.
> Regards
> Jorgen D:
>
|||Thanks for your reply Hilary,
The problem is that my subscribers are anonymous and disconnected (SQL CE on
PDAs), so first of all I have 100+ merge agents and second, properties are
not available since they are not connected. Clicking Properties returns a
"SQL server not found"-error
When the subscriber connects and starts the merge process (pull
subsctiption) somhow the agent wakes up. But where is that "trigger"/"command
line"?
"Hilary Cotter" wrote:
> check this link out:
> http://support.microsoft.com/default...b;en-us;305039
> to use this expand replication monitor, expand the agents folder, expand the
> merge agents folder, right click on your merge agent, select merge agent
> properties, select steps, double click on Run Agent.
> Click on the commands text box, press the end key, press the space key, and
> enter -ForceConvergenceLevel and then the level you wish.
> Then click apply, ok, apply, ok. Then right click again on your merge agent
> and start it up.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
>
> "JorgenD" <JorgenD@.discussions.microsoft.com> wrote in message
> news:ED4B5EE0-8FFD-40D1-8C44-FA295EAB3EFB@.microsoft.com...
> that
> Enterprise
> want
>
>
Monday, March 19, 2012
force close connections
hello!
is there any way to force the server to close all existing USER connections?
i mean, not the system connections or the sql server agent connections, only
the user ones.
Thanks!!!!Not directly. Is this for a certain database? If so, perhaps setting database option restricted user
might help. Also, when you set a database option, you have a rollback option, which will kick out
existing users.
If above doesn't suit you, you could always write a cursor which loops something like sysprocesses
and uses dynamic SQL to KILL the spids you don't want to keep.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER connections?
> i mean, not the system connections or the sql server agent connections, only
> the user ones.
> Thanks!!!!|||On Apr 16, 7:03=A0am, DarthSidious
<DarthSidi...@.discussions.microsoft.com> wrote:
> hello!
> is there any way to force the server to close all existing USER connection=s?
> i mean, not the system connections or the sql server agent connections, on=ly
> the user ones.
> Thanks!!!!
Here is what I use - just pass the database name and run in master:
CREATE PROCEDURE [dbo].[utl_KillUsers] @.dbname varchar(50) as
SET NOCOUNT ON
DECLARE @.strSQL varchar(255)
CREATE table #tmpUsers(
spid int,
eid int,
status varchar(30),
loginname varchar(50),
hostname varchar(50),
blk int,
dbname varchar(50),
cmd varchar(30),
request_id int )
INSERT INTO #tmpUsers EXEC SP_WHO
DECLARE LoginCursor CURSOR
READ_ONLY
FOR SELECT spid, dbname FROM #tmpUsers WHERE dbname =3D @.dbname
DECLARE @.spid varchar(10)
DECLARE @.dbname2 varchar(40)
OPEN LoginCursor
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
WHILE (@.@.fetch_status <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
PRINT 'Killing ' + @.spid
SET @.strSQL =3D 'KILL ' + @.spid
EXEC (@.strSQL)
END
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
END
CLOSE LoginCursor
DEALLOCATE LoginCursor
DROP table #tmpUsers|||In sql 2005 you can also set a database to single user mode and use the WITH
ROLLBACK IMMEDIATE flag. See ALTER DATABASE in BOL. If you wanted to
disconnect ALL user connections you would need to do this for every user
database.
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER
> connections?
> i mean, not the system connections or the sql server agent connections,
> only
> the user ones.
> Thanks!!!!
is there any way to force the server to close all existing USER connections?
i mean, not the system connections or the sql server agent connections, only
the user ones.
Thanks!!!!Not directly. Is this for a certain database? If so, perhaps setting database option restricted user
might help. Also, when you set a database option, you have a rollback option, which will kick out
existing users.
If above doesn't suit you, you could always write a cursor which loops something like sysprocesses
and uses dynamic SQL to KILL the spids you don't want to keep.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER connections?
> i mean, not the system connections or the sql server agent connections, only
> the user ones.
> Thanks!!!!|||On Apr 16, 7:03=A0am, DarthSidious
<DarthSidi...@.discussions.microsoft.com> wrote:
> hello!
> is there any way to force the server to close all existing USER connection=s?
> i mean, not the system connections or the sql server agent connections, on=ly
> the user ones.
> Thanks!!!!
Here is what I use - just pass the database name and run in master:
CREATE PROCEDURE [dbo].[utl_KillUsers] @.dbname varchar(50) as
SET NOCOUNT ON
DECLARE @.strSQL varchar(255)
CREATE table #tmpUsers(
spid int,
eid int,
status varchar(30),
loginname varchar(50),
hostname varchar(50),
blk int,
dbname varchar(50),
cmd varchar(30),
request_id int )
INSERT INTO #tmpUsers EXEC SP_WHO
DECLARE LoginCursor CURSOR
READ_ONLY
FOR SELECT spid, dbname FROM #tmpUsers WHERE dbname =3D @.dbname
DECLARE @.spid varchar(10)
DECLARE @.dbname2 varchar(40)
OPEN LoginCursor
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
WHILE (@.@.fetch_status <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
PRINT 'Killing ' + @.spid
SET @.strSQL =3D 'KILL ' + @.spid
EXEC (@.strSQL)
END
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
END
CLOSE LoginCursor
DEALLOCATE LoginCursor
DROP table #tmpUsers|||In sql 2005 you can also set a database to single user mode and use the WITH
ROLLBACK IMMEDIATE flag. See ALTER DATABASE in BOL. If you wanted to
disconnect ALL user connections you would need to do this for every user
database.
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER
> connections?
> i mean, not the system connections or the sql server agent connections,
> only
> the user ones.
> Thanks!!!!
force close connections
hello!
is there any way to force the server to close all existing USER connections?
i mean, not the system connections or the sql server agent connections, only
the user ones.
Thanks!!!!
Not directly. Is this for a certain database? If so, perhaps setting database option restricted user
might help. Also, when you set a database option, you have a rollback option, which will kick out
existing users.
If above doesn't suit you, you could always write a cursor which loops something like sysprocesses
and uses dynamic SQL to KILL the spids you don't want to keep.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER connections?
> i mean, not the system connections or the sql server agent connections, only
> the user ones.
> Thanks!!!!
|||On Apr 16, 7:03Xam, DarthSidious
<DarthSidi...@.discussions.microsoft.com> wrote:
> hello!
> is there any way to force the server to close all existing USER connections?
> i mean, not the system connections or the sql server agent connections, only
> the user ones.
> Thanks!!!!
Here is what I use - just pass the database name and run in master:
CREATE PROCEDURE [dbo].[utl_KillUsers] @.dbname varchar(50) as
SET NOCOUNT ON
DECLARE @.strSQL varchar(255)
CREATE table #tmpUsers(
spid int,
eid int,
status varchar(30),
loginname varchar(50),
hostname varchar(50),
blk int,
dbname varchar(50),
cmd varchar(30),
request_id int )
INSERT INTO #tmpUsers EXEC SP_WHO
DECLARE LoginCursor CURSOR
READ_ONLY
FOR SELECT spid, dbname FROM #tmpUsers WHERE dbname = @.dbname
DECLARE @.spid varchar(10)
DECLARE @.dbname2 varchar(40)
OPEN LoginCursor
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
WHILE (@.@.fetch_status <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
PRINT 'Killing ' + @.spid
SET @.strSQL = 'KILL ' + @.spid
EXEC (@.strSQL)
END
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
END
CLOSE LoginCursor
DEALLOCATE LoginCursor
DROP table #tmpUsers
|||In sql 2005 you can also set a database to single user mode and use the WITH
ROLLBACK IMMEDIATE flag. See ALTER DATABASE in BOL. If you wanted to
disconnect ALL user connections you would need to do this for every user
database.
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER
> connections?
> i mean, not the system connections or the sql server agent connections,
> only
> the user ones.
> Thanks!!!!
is there any way to force the server to close all existing USER connections?
i mean, not the system connections or the sql server agent connections, only
the user ones.
Thanks!!!!
Not directly. Is this for a certain database? If so, perhaps setting database option restricted user
might help. Also, when you set a database option, you have a rollback option, which will kick out
existing users.
If above doesn't suit you, you could always write a cursor which loops something like sysprocesses
and uses dynamic SQL to KILL the spids you don't want to keep.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER connections?
> i mean, not the system connections or the sql server agent connections, only
> the user ones.
> Thanks!!!!
|||On Apr 16, 7:03Xam, DarthSidious
<DarthSidi...@.discussions.microsoft.com> wrote:
> hello!
> is there any way to force the server to close all existing USER connections?
> i mean, not the system connections or the sql server agent connections, only
> the user ones.
> Thanks!!!!
Here is what I use - just pass the database name and run in master:
CREATE PROCEDURE [dbo].[utl_KillUsers] @.dbname varchar(50) as
SET NOCOUNT ON
DECLARE @.strSQL varchar(255)
CREATE table #tmpUsers(
spid int,
eid int,
status varchar(30),
loginname varchar(50),
hostname varchar(50),
blk int,
dbname varchar(50),
cmd varchar(30),
request_id int )
INSERT INTO #tmpUsers EXEC SP_WHO
DECLARE LoginCursor CURSOR
READ_ONLY
FOR SELECT spid, dbname FROM #tmpUsers WHERE dbname = @.dbname
DECLARE @.spid varchar(10)
DECLARE @.dbname2 varchar(40)
OPEN LoginCursor
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
WHILE (@.@.fetch_status <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
PRINT 'Killing ' + @.spid
SET @.strSQL = 'KILL ' + @.spid
EXEC (@.strSQL)
END
FETCH NEXT FROM LoginCursor INTO @.spid, @.dbname2
END
CLOSE LoginCursor
DEALLOCATE LoginCursor
DROP table #tmpUsers
|||In sql 2005 you can also set a database to single user mode and use the WITH
ROLLBACK IMMEDIATE flag. See ALTER DATABASE in BOL. If you wanted to
disconnect ALL user connections you would need to do this for every user
database.
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:EAF6BCAC-A658-43B9-AEF7-C16423C43210@.microsoft.com...
> hello!
> is there any way to force the server to close all existing USER
> connections?
> i mean, not the system connections or the sql server agent connections,
> only
> the user ones.
> Thanks!!!!
Subscribe to:
Posts (Atom)