Showing posts with label across. Show all posts
Showing posts with label across. Show all posts

Thursday, March 8, 2012

Alter Database statement

Is it possible to issue an alter database statement across servers?
For example
Alter Database Server.Database
Also, the same question with dbcc shrinkdatabase.
Can you do dbcc shrinkdatabase('Server.Database')?
Thanks
Not directly. But if the linked server is configured so that you can execute remote stored
procedures, you can do:
EXEC Server.master.dbo.sp_executesql('ALTER DATABASE dbname...')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy" <Andy@.discussions.microsoft.com> wrote in message
news:73D8641F-7DED-48CA-80C9-762AC78D20C2@.microsoft.com...
> Is it possible to issue an alter database statement across servers?
> For example
> Alter Database Server.Database
> Also, the same question with dbcc shrinkdatabase.
> Can you do dbcc shrinkdatabase('Server.Database')?
> Thanks

Alter Database statement

Is it possible to issue an alter database statement across servers?
For example
Alter Database Server.Database
Also, the same question with dbcc shrinkdatabase.
Can you do dbcc shrinkdatabase('Server.Database')?
ThanksNot directly. But if the linked server is configured so that you can execute remote stored
procedures, you can do:
EXEC Server.master.dbo.sp_executesql('ALTER DATABASE dbname...')
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy" <Andy@.discussions.microsoft.com> wrote in message
news:73D8641F-7DED-48CA-80C9-762AC78D20C2@.microsoft.com...
> Is it possible to issue an alter database statement across servers?
> For example
> Alter Database Server.Database
> Also, the same question with dbcc shrinkdatabase.
> Can you do dbcc shrinkdatabase('Server.Database')?
> Thanks

Alter Database statement

Is it possible to issue an alter database statement across servers?
For example
Alter Database Server.Database
Also, the same question with dbcc shrinkdatabase.
Can you do dbcc shrinkdatabase('Server.Database')?
ThanksNot directly. But if the linked server is configured so that you can execute
remote stored
procedures, you can do:
EXEC Server.master.dbo.sp_executesql('ALTER DATABASE dbname...')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy" <Andy@.discussions.microsoft.com> wrote in message
news:73D8641F-7DED-48CA-80C9-762AC78D20C2@.microsoft.com...
> Is it possible to issue an alter database statement across servers?
> For example
> Alter Database Server.Database
> Also, the same question with dbcc shrinkdatabase.
> Can you do dbcc shrinkdatabase('Server.Database')?
> Thanks

Wednesday, March 7, 2012

Alter Database across linked server

We have approximately 30 servers with about 700 databases.
We are running SQL Server 2005, SP1, on Windows 2003
We need to set Quoted Identifiers ON, as the default setting on all databases.
Linked servers are set up on all servers.
I have created a statement using dynamic sql to loop through all servers and
databases to set QUOTED_IDENTIFIER ON.
This is a sample output of a statement to be executed:
ALTER DATABASE SQL02.AdventureWorks
SET QUOTED_IDENTIFIER OFF
When the statement is executed I get an error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.
To verify my linked server is set up properly, I run the following
successfully:
select * from SQL02.AdventureWorks.Person.Address
Is it possible to run an alter database command across a linked server, and
if so, how do you let SQL Server know which database server is to be used?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200701/1"cbrichards via SQLMonster.com" <u3288@.uwe> wrote in message
news:6c17852baa692@.uwe...
> We have approximately 30 servers with about 700 databases.
> We are running SQL Server 2005, SP1, on Windows 2003
> We need to set Quoted Identifiers ON, as the default setting on all
> databases.
>
> Linked servers are set up on all servers.
> I have created a statement using dynamic sql to loop through all servers
> and
> databases to set QUOTED_IDENTIFIER ON.
> This is a sample output of a statement to be executed:
> ALTER DATABASE SQL02.AdventureWorks
> SET QUOTED_IDENTIFIER OFF
> When the statement is executed I get an error:
> Msg 102, Level 15, State 1, Line 1
> Incorrect syntax near '.'.
> To verify my linked server is set up properly, I run the following
> successfully:
> select * from SQL02.AdventureWorks.Person.Address
> Is it possible to run an alter database command across a linked server,
> and
> if so, how do you let SQL Server know which database server is to be used?
>
Yes. In 2005 you can execute arbitrary batches, including stored procedures
and DDL, at remote servers with the EXEC ... AT statement.
eg:
exec ( '
ALTER DATABASE AdventureWorks SET QUOTED_IDENTIFIER OFF
' ) at SQL02
David

Alter Database across linked server

We have approximately 30 servers with about 700 databases.
We are running SQL Server 2005, SP1, on Windows 2003
We need to set Quoted Identifiers ON, as the default setting on all database
s.
Linked servers are set up on all servers.
I have created a statement using dynamic sql to loop through all servers and
databases to set QUOTED_IDENTIFIER ON.
This is a sample output of a statement to be executed:
ALTER DATABASE SQL02.AdventureWorks
SET QUOTED_IDENTIFIER OFF
When the statement is executed I get an error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.
To verify my linked server is set up properly, I run the following
successfully:
select * from SQL02.AdventureWorks.Person.Address
Is it possible to run an alter database command across a linked server, and
if so, how do you let SQL Server know which database server is to be used?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200701/1"cbrichards via droptable.com" <u3288@.uwe> wrote in message
news:6c17852baa692@.uwe...
> We have approximately 30 servers with about 700 databases.
> We are running SQL Server 2005, SP1, on Windows 2003
> We need to set Quoted Identifiers ON, as the default setting on all
> databases.
>
> Linked servers are set up on all servers.
> I have created a statement using dynamic sql to loop through all servers
> and
> databases to set QUOTED_IDENTIFIER ON.
> This is a sample output of a statement to be executed:
> ALTER DATABASE SQL02.AdventureWorks
> SET QUOTED_IDENTIFIER OFF
> When the statement is executed I get an error:
> Msg 102, Level 15, State 1, Line 1
> Incorrect syntax near '.'.
> To verify my linked server is set up properly, I run the following
> successfully:
> select * from SQL02.AdventureWorks.Person.Address
> Is it possible to run an alter database command across a linked server,
> and
> if so, how do you let SQL Server know which database server is to be used?
>
Yes. In 2005 you can execute arbitrary batches, including stored procedures
and DDL, at remote servers with the EXEC ... AT statement.
eg:
exec ( '
ALTER DATABASE AdventureWorks SET QUOTED_IDENTIFIER OFF
' ) at SQL02
David

Alter Database across linked server

We have approximately 30 servers with about 700 databases.
We are running SQL Server 2005, SP1, on Windows 2003
We need to set Quoted Identifiers ON, as the default setting on all databases.
Linked servers are set up on all servers.
I have created a statement using dynamic sql to loop through all servers and
databases to set QUOTED_IDENTIFIER ON.
This is a sample output of a statement to be executed:
ALTER DATABASE SQL02.AdventureWorks
SET QUOTED_IDENTIFIER OFF
When the statement is executed I get an error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.
To verify my linked server is set up properly, I run the following
successfully:
select * from SQL02.AdventureWorks.Person.Address
Is it possible to run an alter database command across a linked server, and
if so, how do you let SQL Server know which database server is to be used?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums.aspx/sql-server/200701/1
"cbrichards via droptable.com" <u3288@.uwe> wrote in message
news:6c17852baa692@.uwe...
> We have approximately 30 servers with about 700 databases.
> We are running SQL Server 2005, SP1, on Windows 2003
> We need to set Quoted Identifiers ON, as the default setting on all
> databases.
>
> Linked servers are set up on all servers.
> I have created a statement using dynamic sql to loop through all servers
> and
> databases to set QUOTED_IDENTIFIER ON.
> This is a sample output of a statement to be executed:
> ALTER DATABASE SQL02.AdventureWorks
> SET QUOTED_IDENTIFIER OFF
> When the statement is executed I get an error:
> Msg 102, Level 15, State 1, Line 1
> Incorrect syntax near '.'.
> To verify my linked server is set up properly, I run the following
> successfully:
> select * from SQL02.AdventureWorks.Person.Address
> Is it possible to run an alter database command across a linked server,
> and
> if so, how do you let SQL Server know which database server is to be used?
>
Yes. In 2005 you can execute arbitrary batches, including stored procedures
and DDL, at remote servers with the EXEC ... AT statement.
eg:
exec ( '
ALTER DATABASE AdventureWorks SET QUOTED_IDENTIFIER OFF
' ) at SQL02
David

Sunday, February 19, 2012

Allowing an applicaiton to create it's own tables

I have recently come across a situation where someone has asked me to
give an application the ability to create it's own data tables, stored
procs and other items in SQL Server 2000 if they do not exist in the
database that the client has pointed the application too. I find this
very troubling and have come up with a number of reasons why I don't
think this is a good idea, but would like some input from any DBA's or
Microsoft MVPs that care to comment on this situation. I was
considering posting my own ideas, but I think I would rather compare my
idea's to what input I recieve from the community afterwards so that I
have not 'lead the witness' or tainted the input from the community.
Thank you all in advance for any input, I appreciate any professional
opinions I can get my hands on.
Sincerely
russ
I'm not an MVP, but I have an opinion. Not sure what kind of
applicaiton you're writing. If you're writing a database utility
(Enterprise Manger, Embarcadero, etc.) then sure, this sounds like
something that's well in the scope of that. If you're writing any sort
of app that's going to be used by a a non-developer/non-DBA, then why
would they need access? If you have a one user application and that one
user is the DBA, then yes - maybe. But - in general, very bad idea. I
agree with you. The user/application could wreak havoc on the DB.
rhaley@.axys.com wrote:
> I have recently come across a situation where someone has asked me to
> give an application the ability to create it's own data tables, stored
> procs and other items in SQL Server 2000 if they do not exist in the
> database that the client has pointed the application too. I find this
> very troubling and have come up with a number of reasons why I don't
> think this is a good idea, but would like some input from any DBA's or
> Microsoft MVPs that care to comment on this situation. I was
> considering posting my own ideas, but I think I would rather compare my
> idea's to what input I recieve from the community afterwards so that I
> have not 'lead the witness' or tainted the input from the community.
> Thank you all in advance for any input, I appreciate any professional
> opinions I can get my hands on.
> Sincerely
> russ
|||If this is for an end user, (?) granting an end user the ability to write
his own Stored Procs would be out of the question for most DBA's. I don't
know what these SP's may do, how much resources they may consume, what
security I would need to assign, what blocking/ deadlocking they may
introduce, etc.
<unc27932@.yahoo.com> wrote in message
news:1123175440.352742.216950@.g14g2000cwa.googlegr oups.com...
> I'm not an MVP, but I have an opinion. Not sure what kind of
> applicaiton you're writing. If you're writing a database utility
> (Enterprise Manger, Embarcadero, etc.) then sure, this sounds like
> something that's well in the scope of that. If you're writing any sort
> of app that's going to be used by a a non-developer/non-DBA, then why
> would they need access? If you have a one user application and that one
> user is the DBA, then yes - maybe. But - in general, very bad idea. I
> agree with you. The user/application could wreak havoc on the DB.
> rhaley@.axys.com wrote:
>
|||The customer wants an installation program? That's fine. The customer
wants an installation program that runs each time he starts up the app?
That's a bit more unusual! It seems to me that if the tables and procs
weren't there then I'd want to know about it, not have the DB
automatically create a clean installation.
What is the application for and why wouldn't the tables be there when
the app is run?
Also, if this is a multi-user app and you roll out a new release then
how will you ensure that everyone gets the new release simultaneously?
Otherwise an extant prior release could end up replacing your new
version of the database with an older one.
David Portas
SQL Server MVP
|||The idea from the client was that they would be able to point this
application at any database and use it as an 'Add On' application.
Although this idea is neat, it's kinda half baked (as he has agreed
since I showed him some comments).
All really great points guys, thank you very much. As you have all
pointed out, it's rather silly to have an application just re-create
tables and other DB items 'willy nilly' when it doesn't find them. Some
other issues I felt were of concern were:
- The only way to create tables in a database is to give the
application SA or CREATE TABLE rights on the database or database
instance, which is very uncool for an application that users have
access too.
- How do you ensure that the tables and SPs are of the same version
that the application needs without using System Tables or
INFORMATION_SCHEMA and itterating through every bloody column and
comparing data types and field lengths?
- What if user JSmith creates the tables and then later they change to
a different user? The application won't be able to find the tables
anymore and will re-create them, effectively 'losing' the old data
- "duh... Master sounds like a good database to put this in..."
- And last but not least, I'm on a small network and there are 17
exposed instances of SQL server/MSDE kicking around... have fun finding
the right 'version' of the tables ever again.
I think the solution is probably what David was hinting at - create a
separate installation program for the database and/or tables that
prompts for credentials (UID/PWD) so that an administrator with valid
sa or Create Table rights can take care of things. This will save alot
of headaches and keep a truck load of DBAs from coming over to my
office and lynching me!
Cheers guys!
Russ

Allowing an applicaiton to create it's own tables

I have recently come across a situation where someone has asked me to
give an application the ability to create it's own data tables, stored
procs and other items in SQL Server 2000 if they do not exist in the
database that the client has pointed the application too. I find this
very troubling and have come up with a number of reasons why I don't
think this is a good idea, but would like some input from any DBA's or
Microsoft MVPs that care to comment on this situation. I was
considering posting my own ideas, but I think I would rather compare my
idea's to what input I recieve from the community afterwards so that I
have not 'lead the witness' or tainted the input from the community.
Thank you all in advance for any input, I appreciate any professional
opinions I can get my hands on.
Sincerely
russI'm not an MVP, but I have an opinion. Not sure what kind of
applicaiton you're writing. If you're writing a database utility
(Enterprise Manger, Embarcadero, etc.) then sure, this sounds like
something that's well in the scope of that. If you're writing any sort
of app that's going to be used by a a non-developer/non-DBA, then why
would they need access? If you have a one user application and that one
user is the DBA, then yes - maybe. But - in general, very bad idea. I
agree with you. The user/application could wreak havoc on the DB.
rhaley@.axys.com wrote:
> I have recently come across a situation where someone has asked me to
> give an application the ability to create it's own data tables, stored
> procs and other items in SQL Server 2000 if they do not exist in the
> database that the client has pointed the application too. I find this
> very troubling and have come up with a number of reasons why I don't
> think this is a good idea, but would like some input from any DBA's or
> Microsoft MVPs that care to comment on this situation. I was
> considering posting my own ideas, but I think I would rather compare my
> idea's to what input I recieve from the community afterwards so that I
> have not 'lead the witness' or tainted the input from the community.
> Thank you all in advance for any input, I appreciate any professional
> opinions I can get my hands on.
> Sincerely
> russ|||If this is for an end user, (?) granting an end user the ability to write
his own Stored Procs would be out of the question for most DBA's. I don't
know what these SP's may do, how much resources they may consume, what
security I would need to assign, what blocking/ deadlocking they may
introduce, etc.
<unc27932@.yahoo.com> wrote in message
news:1123175440.352742.216950@.g14g2000cwa.googlegroups.com...
> I'm not an MVP, but I have an opinion. Not sure what kind of
> applicaiton you're writing. If you're writing a database utility
> (Enterprise Manger, Embarcadero, etc.) then sure, this sounds like
> something that's well in the scope of that. If you're writing any sort
> of app that's going to be used by a a non-developer/non-DBA, then why
> would they need access? If you have a one user application and that one
> user is the DBA, then yes - maybe. But - in general, very bad idea. I
> agree with you. The user/application could wreak havoc on the DB.
> rhaley@.axys.com wrote:
>|||The customer wants an installation program? That's fine. The customer
wants an installation program that runs each time he starts up the app?
That's a bit more unusual! It seems to me that if the tables and procs
weren't there then I'd want to know about it, not have the DB
automatically create a clean installation.
What is the application for and why wouldn't the tables be there when
the app is run?
Also, if this is a multi-user app and you roll out a new release then
how will you ensure that everyone gets the new release simultaneously?
Otherwise an extant prior release could end up replacing your new
version of the database with an older one.
David Portas
SQL Server MVP
--|||The idea from the client was that they would be able to point this
application at any database and use it as an 'Add On' application.
Although this idea is neat, it's kinda half baked (as he has agreed
since I showed him some comments).
All really great points guys, thank you very much. As you have all
pointed out, it's rather silly to have an application just re-create
tables and other DB items 'willy nilly' when it doesn't find them. Some
other issues I felt were of concern were:
- The only way to create tables in a database is to give the
application SA or CREATE TABLE rights on the database or database
instance, which is very uncool for an application that users have
access too.
- How do you ensure that the tables and SPs are of the same version
that the application needs without using System Tables or
INFORMATION_SCHEMA and itterating through every bloody column and
comparing data types and field lengths?
- What if user JSmith creates the tables and then later they change to
a different user? The application won't be able to find the tables
anymore and will re-create them, effectively 'losing' the old data
- "duh... Master sounds like a good database to put this in..."
- And last but not least, I'm on a small network and there are 17
exposed instances of SQL server/MSDE kicking around... have fun finding
the right 'version' of the tables ever again.
I think the solution is probably what David was hinting at - create a
separate installation program for the database and/or tables that
prompts for credentials (UID/PWD) so that an administrator with valid
sa or Create Table rights can take care of things. This will save alot
of headaches and keep a truck load of DBAs from coming over to my
office and lynching me!
Cheers guys!
Russ

Allowing an applicaiton to create it's own tables

I have recently come across a situation where someone has asked me to
give an application the ability to create it's own data tables, stored
procs and other items in SQL Server 2000 if they do not exist in the
database that the client has pointed the application too. I find this
very troubling and have come up with a number of reasons why I don't
think this is a good idea, but would like some input from any DBA's or
Microsoft MVPs that care to comment on this situation. I was
considering posting my own ideas, but I think I would rather compare my
idea's to what input I recieve from the community afterwards so that I
have not 'lead the witness' or tainted the input from the community.
Thank you all in advance for any input, I appreciate any professional
opinions I can get my hands on.
Sincerely
russI'm not an MVP, but I have an opinion. Not sure what kind of
applicaiton you're writing. If you're writing a database utility
(Enterprise Manger, Embarcadero, etc.) then sure, this sounds like
something that's well in the scope of that. If you're writing any sort
of app that's going to be used by a a non-developer/non-DBA, then why
would they need access? If you have a one user application and that one
user is the DBA, then yes - maybe. But - in general, very bad idea. I
agree with you. The user/application could wreak havoc on the DB.
rhaley@.axys.com wrote:
> I have recently come across a situation where someone has asked me to
> give an application the ability to create it's own data tables, stored
> procs and other items in SQL Server 2000 if they do not exist in the
> database that the client has pointed the application too. I find this
> very troubling and have come up with a number of reasons why I don't
> think this is a good idea, but would like some input from any DBA's or
> Microsoft MVPs that care to comment on this situation. I was
> considering posting my own ideas, but I think I would rather compare my
> idea's to what input I recieve from the community afterwards so that I
> have not 'lead the witness' or tainted the input from the community.
> Thank you all in advance for any input, I appreciate any professional
> opinions I can get my hands on.
> Sincerely
> russ|||If this is for an end user, (?) granting an end user the ability to write
his own Stored Procs would be out of the question for most DBA's. I don't
know what these SP's may do, how much resources they may consume, what
security I would need to assign, what blocking/ deadlocking they may
introduce, etc.
<unc27932@.yahoo.com> wrote in message
news:1123175440.352742.216950@.g14g2000cwa.googlegroups.com...
> I'm not an MVP, but I have an opinion. Not sure what kind of
> applicaiton you're writing. If you're writing a database utility
> (Enterprise Manger, Embarcadero, etc.) then sure, this sounds like
> something that's well in the scope of that. If you're writing any sort
> of app that's going to be used by a a non-developer/non-DBA, then why
> would they need access? If you have a one user application and that one
> user is the DBA, then yes - maybe. But - in general, very bad idea. I
> agree with you. The user/application could wreak havoc on the DB.
> rhaley@.axys.com wrote:
>> I have recently come across a situation where someone has asked me to
>> give an application the ability to create it's own data tables, stored
>> procs and other items in SQL Server 2000 if they do not exist in the
>> database that the client has pointed the application too. I find this
>> very troubling and have come up with a number of reasons why I don't
>> think this is a good idea, but would like some input from any DBA's or
>> Microsoft MVPs that care to comment on this situation. I was
>> considering posting my own ideas, but I think I would rather compare my
>> idea's to what input I recieve from the community afterwards so that I
>> have not 'lead the witness' or tainted the input from the community.
>> Thank you all in advance for any input, I appreciate any professional
>> opinions I can get my hands on.
>> Sincerely
>> russ
>|||The customer wants an installation program? That's fine. The customer
wants an installation program that runs each time he starts up the app?
That's a bit more unusual! It seems to me that if the tables and procs
weren't there then I'd want to know about it, not have the DB
automatically create a clean installation.
What is the application for and why wouldn't the tables be there when
the app is run?
Also, if this is a multi-user app and you roll out a new release then
how will you ensure that everyone gets the new release simultaneously?
Otherwise an extant prior release could end up replacing your new
version of the database with an older one.
--
David Portas
SQL Server MVP
--|||The idea from the client was that they would be able to point this
application at any database and use it as an 'Add On' application.
Although this idea is neat, it's kinda half baked (as he has agreed
since I showed him some comments).
All really great points guys, thank you very much. As you have all
pointed out, it's rather silly to have an application just re-create
tables and other DB items 'willy nilly' when it doesn't find them. Some
other issues I felt were of concern were:
- The only way to create tables in a database is to give the
application SA or CREATE TABLE rights on the database or database
instance, which is very uncool for an application that users have
access too.
- How do you ensure that the tables and SPs are of the same version
that the application needs without using System Tables or
INFORMATION_SCHEMA and itterating through every bloody column and
comparing data types and field lengths?
- What if user JSmith creates the tables and then later they change to
a different user? The application won't be able to find the tables
anymore and will re-create them, effectively 'losing' the old data
- "duh... Master sounds like a good database to put this in..."
- And last but not least, I'm on a small network and there are 17
exposed instances of SQL server/MSDE kicking around... have fun finding
the right 'version' of the tables ever again.
I think the solution is probably what David was hinting at - create a
separate installation program for the database and/or tables that
prompts for credentials (UID/PWD) so that an administrator with valid
sa or Create Table rights can take care of things. This will save alot
of headaches and keep a truck load of DBAs from coming over to my
office and lynching me!
Cheers guys!
Russ

Sunday, February 12, 2012

All tables under partitioned union view get locked - how to reduce?

Hi. We are using a partitioned view across a number of tables. They are
partitioned on a single column. We use the view to insert and update rows in
the underlying tables.
When loading all the rows for table XYZ through the view we find that SQL
Server is creating IX locks against all of the tables even though all the
rows are for one table only as identified by the check constraint on the
partitioned column.
Is there any way to get SQL Server to lock only the table that will be
affected?
McGy
[url]http://mcgy.blogspot.com[/url]"McGy" <anon@.anon.com> wrote in message
news:eIsUGsjhGHA.4368@.TK2MSFTNGP03.phx.gbl...
> Hi. We are using a partitioned view across a number of tables. They are
> partitioned on a single column. We use the view to insert and update rows
> in the underlying tables.
> When loading all the rows for table XYZ through the view we find that SQL
> Server is creating IX locks against all of the tables even though all the
> rows are for one table only as identified by the check constraint on the
> partitioned column.
> Is there any way to get SQL Server to lock only the table that will be
> affected?
>
Partitioned views have serious limitations. You should expect to have to
directly address the underlying tables for many operations. Qu|||Cheers David. I am considering duplicating the load stored procedures, 1 per
table, so as to remove the dependency on the partitioned view. It will make
maintenance a bit more complex but ultimately performance should improve.
Does that sound sensible?
Thanks.
McGy
[url]http://mcgy.blogspot.com[/url]
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:O4TVf3khGHA.3860@.TK2MSFTNGP02.phx.gbl...
> "McGy" <anon@.anon.com> wrote in message
> news:eIsUGsjhGHA.4368@.TK2MSFTNGP03.phx.gbl...
rows
SQL
the
> Partitioned views have serious limitations. You should expect to have to
> directly address the underlying tables for many operations. Qu
>|||"McGy" <anon@.anon.com> wrote in message
news:%23AUMJNvhGHA.4252@.TK2MSFTNGP04.phx.gbl...
> Cheers David. I am considering duplicating the load stored procedures, 1
> per
> table, so as to remove the dependency on the partitioned view. It will
> make
> maintenance a bit more complex but ultimately performance should improve.
> Does that sound sensible?
>
Yes. And you can always use dynamic SQL to load the table.
David|||The only problem with dynamic SQL is that the stored procedure would be a
nightmare to maintain in that form as it uses lots of variables. Also,
because of the stored procedure's size it takes several seconds to compile.
Presumably we would take that compilation hit each time the dynamic SQL is
constructed and prepared for execution?
McGy
[url]http://mcgy.blogspot.com[/url]
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:#cVWYyzhGHA.1612@.TK2MSFTNGP04.phx.gbl...
> "McGy" <anon@.anon.com> wrote in message
> news:%23AUMJNvhGHA.4252@.TK2MSFTNGP04.phx.gbl...
improve.
> Yes. And you can always use dynamic SQL to load the table.
> David
>|||Not necessarily; if you use sp_executeSQL with variables you are
essentially creating a parameterized SQL statement which increases the
likelihood that the execution plan will be reused.
This issue is interesting to me; we use partioned views as well.
However all of our inserts are done with bulk load methods, so locking
hasn't been a problem (yet). I understand the SQL 2005's partitoned
tables are much better than the the views; yet another reason to
consider upgrading.
Stu
McGy wrote:
> The only problem with dynamic SQL is that the stored procedure would be a
> nightmare to maintain in that form as it uses lots of variables. Also,
> because of the stored procedure's size it takes several seconds to compile
.
> Presumably we would take that compilation hit each time the dynamic SQL is
> constructed and prepared for execution?
> --
> McGy
> [url]http://mcgy.blogspot.com[/url]
>
> "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> message news:#cVWYyzhGHA.1612@.TK2MSFTNGP04.phx.gbl...
> improve.|||Hmmm. Interesting point on the sp_executesql. I'll take a look.
We use bulk insert too; but we also need to apply a bunch of rules to the
records that get loaded. They get loaded twice: once in to a transaction
table which are all inserts - the other in to an aggregation table that
applies certain rules depending upon what type the transaction is.
Just thought of a problem on the dynamic SQL front. The stored procedure
would be well in excess of the 8000 char limit on variable sizes. Is there a
way to work around that?
McGy
[url]http://mcgy.blogspot.com[/url]
"Stu" <stuart.ainsworth@.gmail.com> wrote in message
news:1149427023.769413.5440@.i39g2000cwa.googlegroups.com...
> Not necessarily; if you use sp_executeSQL with variables you are
> essentially creating a parameterized SQL statement which increases the
> likelihood that the execution plan will be reused.
> This issue is interesting to me; we use partioned views as well.
> However all of our inserts are done with bulk load methods, so locking
> hasn't been a problem (yet). I understand the SQL 2005's partitoned
> tables are much better than the the views; yet another reason to
> consider upgrading.
> Stu
> McGy wrote:
a
compile.
is
procedures, 1
will
>|||McGy (anon@.anon.com) writes:
> Hi. We are using a partitioned view across a number of tables. They are
> partitioned on a single column. We use the view to insert and update
> rows in the underlying tables.
> When loading all the rows for table XYZ through the view we find that SQL
> Server is creating IX locks against all of the tables even though all the
> rows are for one table only as identified by the check constraint on the
> partitioned column.
> Is there any way to get SQL Server to lock only the table that will be
> affected?
Are the intent locks causing any real problems? I ran a quick test, and
I was not able detect any locking problems, but I might have missed
something. (I was only testing concurrent SELECT statements.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Hi Erland. I am not actually sure if those IX locks are causing a problem.
What is the impact of an IX lock? When we were loading multiple files in
production we noticed that some were being blocked waiting for others to
complete. We assumed it was because of the view creating locks against all
the tables - but perhaps not?
McGy
[url]http://mcgy.blogspot.com[/url]
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns97D9732464F2Yazorman@.127.0.0.1...
> McGy (anon@.anon.com) writes:
> Are the intent locks causing any real problems? I ran a quick test, and
> I was not able detect any locking problems, but I might have missed
> something. (I was only testing concurrent SELECT statements.)
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx|||McGy (anon@.anon.com) writes:
> Hi Erland. I am not actually sure if those IX locks are causing a problem.
> What is the impact of an IX lock? When we were loading multiple files in
> production we noticed that some were being blocked waiting for others to
> complete. We assumed it was because of the view creating locks against all
> the tables - but perhaps not?
The purpose of an intent lock is to tell "I am working here, so don't
try to take all this place for your own".
If a transaction updates a few rows in a table it acquires an X lock
on these rows, and also an IX lock on the table. This prevents other
processes from getting an X-lock on the table. Or put into other words,
the process that wants an exclusive lock on the table, does not need to
check if any rows are currently locked.
In case of the partitioned view the IX locks are there to prevent other
processes from acquire exclusive locks on the other tables, as there
could suddenly appear a row that should be inserted the other tables.
SQL Server cannot conclude that all data that is being inserted goes
only into one table in the view.
So, yes, if you have different insert processes in parallel, they will
block each other. And a process what would try "SELECT COUNT(*) FROM
pview" or anything else that requires a scan would also probably be
blocked, even with a condition that filtered out the table being
loaded.
If you want to run parallel loads at maximum speeds, you will probably
have to load into the underlying tables directly.
I will have to admit that I had read up in Books Online on what an
intent lock really is.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx