Hello, is there a way to make a sql statement that checks disk space and
returns a value if it is below x%?Hi,
See the below query, values for each drive will returned in mega bytes.
create table space_check (drive_letter char(1), space_free int)
insert into tmp exec xp_fixeddrives
select * from space_check where space_free < 20
Thanks
Hari
SQL Server MVP
"Gervaise" <Gervaise@.discussions.microsoft.com> wrote in message
news:86C35096-4F7D-4CBB-8A1A-9BDBF028F0E7@.microsoft.com...
> Hello, is there a way to make a sql statement that checks disk space and
> returns a value if it is below x%?
2012年3月27日星期二
2012年3月19日星期一
disconnect users
Hi,
I was wondering if there is a stored procedure that could disconnect users.
I have job which does some integrity checks, but for one database it
always fails. There is always a connection open. That particular
useraccount is for the oracle applicationserver which should remain active.
How can i resolve this matter and still do maintenance?Do you want to disconnect the users, or not disconnect that user?
If you want to disconnect the users:
USE <databasename>
GO
ALTER DATABASE <databasename> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
(note, this will force all users out and cause any transactions they're in
to roll back -- immediately. There is also a time option; look up syntax in
BOL.)
To allow other users to connect once you're done:
ALTER DATABASE <databasename> SET MULTI_USER
GO
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Jason" <jasonlewis@.hotmail.com> wrote in message
news:%23Qqt7rkeGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Hi,
> I was wondering if there is a stored procedure that could disconnect
> users.
> I have job which does some integrity checks, but for one database it
> always fails. There is always a connection open. That particular
> useraccount is for the oracle applicationserver which should remain
> active.
> How can i resolve this matter and still do maintenance?
I was wondering if there is a stored procedure that could disconnect users.
I have job which does some integrity checks, but for one database it
always fails. There is always a connection open. That particular
useraccount is for the oracle applicationserver which should remain active.
How can i resolve this matter and still do maintenance?Do you want to disconnect the users, or not disconnect that user?
If you want to disconnect the users:
USE <databasename>
GO
ALTER DATABASE <databasename> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
(note, this will force all users out and cause any transactions they're in
to roll back -- immediately. There is also a time option; look up syntax in
BOL.)
To allow other users to connect once you're done:
ALTER DATABASE <databasename> SET MULTI_USER
GO
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Jason" <jasonlewis@.hotmail.com> wrote in message
news:%23Qqt7rkeGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Hi,
> I was wondering if there is a stored procedure that could disconnect
> users.
> I have job which does some integrity checks, but for one database it
> always fails. There is always a connection open. That particular
> useraccount is for the oracle applicationserver which should remain
> active.
> How can i resolve this matter and still do maintenance?
disconnect users
Hi,
I was wondering if there is a stored procedure that could disconnect users.
I have job which does some integrity checks, but for one database it
always fails. There is always a connection open. That particular
useraccount is for the oracle applicationserver which should remain active.
How can i resolve this matter and still do maintenance?Do you want to disconnect the users, or not disconnect that user?
If you want to disconnect the users:
USE <databasename>
GO
ALTER DATABASE <databasename> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
(note, this will force all users out and cause any transactions they're in
to roll back -- immediately. There is also a time option; look up syntax in
BOL.)
To allow other users to connect once you're done:
ALTER DATABASE <databasename> SET MULTI_USER
GO
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Jason" <jasonlewis@.hotmail.com> wrote in message
news:%23Qqt7rkeGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Hi,
> I was wondering if there is a stored procedure that could disconnect
> users.
> I have job which does some integrity checks, but for one database it
> always fails. There is always a connection open. That particular
> useraccount is for the oracle applicationserver which should remain
> active.
> How can i resolve this matter and still do maintenance?
I was wondering if there is a stored procedure that could disconnect users.
I have job which does some integrity checks, but for one database it
always fails. There is always a connection open. That particular
useraccount is for the oracle applicationserver which should remain active.
How can i resolve this matter and still do maintenance?Do you want to disconnect the users, or not disconnect that user?
If you want to disconnect the users:
USE <databasename>
GO
ALTER DATABASE <databasename> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
(note, this will force all users out and cause any transactions they're in
to roll back -- immediately. There is also a time option; look up syntax in
BOL.)
To allow other users to connect once you're done:
ALTER DATABASE <databasename> SET MULTI_USER
GO
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Jason" <jasonlewis@.hotmail.com> wrote in message
news:%23Qqt7rkeGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Hi,
> I was wondering if there is a stored procedure that could disconnect
> users.
> I have job which does some integrity checks, but for one database it
> always fails. There is always a connection open. That particular
> useraccount is for the oracle applicationserver which should remain
> active.
> How can i resolve this matter and still do maintenance?
2012年2月14日星期二
Disable dependence checks when creating view
Is it possible to disable checks for existance of referenced tables(views,
user functions) when creating new view
Thanks in advance.Only way would be through CREATE SCHEMA:
CREATE SCHEMA AUTHORIZATION ross
create view v as select * from t
create table t(c1 int)
More information in Books Online.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Amid" <Amid@.discussions.microsoft.com> wrote in message
news:DEFF0F05-66DD-4ABF-A483-9D934E8A529C@.microsoft.com...
> Is it possible to disable checks for existance of referenced tables(views,
> user functions) when creating new view
> Thanks in advance.|||Thanks for the quick reply.
What if i'm unable to create table [t] within the same statement where [v]
is created?
I need to create it much later.
Any help will be appreciated.
"Tibor Karaszi" wrote:
> Only way would be through CREATE SCHEMA:
> CREATE SCHEMA AUTHORIZATION ross
> create view v as select * from t
> create table t(c1 int)
> More information in Books Online.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Amid" <Amid@.discussions.microsoft.com> wrote in message
> news:DEFF0F05-66DD-4ABF-A483-9D934E8A529C@.microsoft.com...
>|||You can't do that. When a view is created, SQL Server need to populate the s
ystem tables
(syscolumns) with the columns that the view has (the SELECT in the view defi
nition). SQL Server
cannot do that if the table(s) that the view uses doesn't exist.
Why do you have this need? Sounds like a strange requirement to me...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Amid" <Amid@.discussions.microsoft.com> wrote in message
news:2C520E2E-FE0C-41D7-95C8-DA19CB87A78F@.microsoft.com...
> Thanks for the quick reply.
> What if i'm unable to create table [t] within the same statement where [v]
> is created?
> I need to create it much later.
> Any help will be appreciated.
> "Tibor Karaszi" wrote:
>|||I need to make copy of the database structure (tables, views, sp, uddt, uf,
constraints etc) with several modifications. Unfortunately original database
may me inconsistent (views, user functions in it may refer to the others
database tables or views). Now I cant gain access to that tables but
structure has to be copied. Thus I need to create views and user function
(sp) without actually having needed tables or views.
Thanks.
"Tibor Karaszi" wrote:
> You can't do that. When a view is created, SQL Server need to populate the
system tables
> (syscolumns) with the columns that the view has (the SELECT in the view de
finition). SQL Server
> cannot do that if the table(s) that the view uses doesn't exist.
> Why do you have this need? Sounds like a strange requirement to me...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Amid" <Amid@.discussions.microsoft.com> wrote in message
> news:2C520E2E-FE0C-41D7-95C8-DA19CB87A78F@.microsoft.com...
>
user functions) when creating new view
Thanks in advance.Only way would be through CREATE SCHEMA:
CREATE SCHEMA AUTHORIZATION ross
create view v as select * from t
create table t(c1 int)
More information in Books Online.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Amid" <Amid@.discussions.microsoft.com> wrote in message
news:DEFF0F05-66DD-4ABF-A483-9D934E8A529C@.microsoft.com...
> Is it possible to disable checks for existance of referenced tables(views,
> user functions) when creating new view
> Thanks in advance.|||Thanks for the quick reply.
What if i'm unable to create table [t] within the same statement where [v]
is created?
I need to create it much later.
Any help will be appreciated.
"Tibor Karaszi" wrote:
> Only way would be through CREATE SCHEMA:
> CREATE SCHEMA AUTHORIZATION ross
> create view v as select * from t
> create table t(c1 int)
> More information in Books Online.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Amid" <Amid@.discussions.microsoft.com> wrote in message
> news:DEFF0F05-66DD-4ABF-A483-9D934E8A529C@.microsoft.com...
>|||You can't do that. When a view is created, SQL Server need to populate the s
ystem tables
(syscolumns) with the columns that the view has (the SELECT in the view defi
nition). SQL Server
cannot do that if the table(s) that the view uses doesn't exist.
Why do you have this need? Sounds like a strange requirement to me...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Amid" <Amid@.discussions.microsoft.com> wrote in message
news:2C520E2E-FE0C-41D7-95C8-DA19CB87A78F@.microsoft.com...
> Thanks for the quick reply.
> What if i'm unable to create table [t] within the same statement where [v]
> is created?
> I need to create it much later.
> Any help will be appreciated.
> "Tibor Karaszi" wrote:
>|||I need to make copy of the database structure (tables, views, sp, uddt, uf,
constraints etc) with several modifications. Unfortunately original database
may me inconsistent (views, user functions in it may refer to the others
database tables or views). Now I cant gain access to that tables but
structure has to be copied. Thus I need to create views and user function
(sp) without actually having needed tables or views.
Thanks.
"Tibor Karaszi" wrote:
> You can't do that. When a view is created, SQL Server need to populate the
system tables
> (syscolumns) with the columns that the view has (the SELECT in the view de
finition). SQL Server
> cannot do that if the table(s) that the view uses doesn't exist.
> Why do you have this need? Sounds like a strange requirement to me...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Amid" <Amid@.discussions.microsoft.com> wrote in message
> news:2C520E2E-FE0C-41D7-95C8-DA19CB87A78F@.microsoft.com...
>
订阅:
博文 (Atom)