Showing posts with label attribute. Show all posts
Showing posts with label attribute. Show all posts

Thursday, March 22, 2012

check if the database is currently being backed up

How can I check if the database is currently being backed up?

Seems like that should be a property, but it's not an attribute of the DATABASEPROPERTY function.

Thanks

You can check sp_who/spwho2 to find out if any database is being backed up on the server. This involves manual intervention to look at the output of above SP's. Are you trying to retrieve that information interactively and do some other action or what are you trying to achieve?

|||I am trying to have certain logic kick off based on database is being backed. I know I can query the sysprocesses, which is what sp_who2 does, and look for 'BACKUP' string, but I was wondering if there's a better way.|||

I am not sure if its a good idea to have separate logic if the database is being backed up. Anyway, if the backup task is coming from Sql job, you should be able to query the job status.

|||

Check the Log Reuse description when you query sys.databases, and you can tell if a backup is running.

|||

Glenn,

I am not sure if we can use Log Reuse description to find if the database is currently being backed up. I have tried it on 9.00.1399.06 build and while the db is being backed up, log_reuse_wait is 0 and desc says 'NOTHING'. Did I miss something how this can be used?

|||

I figured it now. I had to do BACKUP LOG to see the values. Paul's article on this helped me to understand it better. Thanks to KaliBaba & Glenn, I learned something new today.

|||

Glenn,

I think you're talking about log_reuse_wait_desc in sysdatabases, but that's only talking about log backup,

and sql 2005. I needed to clarify, but I need this for sql 2000 as well. Any suggestions other that sysprocesses?

Thanks

Wednesday, March 7, 2012

CHECK

Hi All,
In my table I have 'filial' attribute(field), and I need check this as
folow:
If 'filial' = TRUE the attributes 'cnpj_da_matriz' and 'numero_de_filiais'
can not be NULL else if 'filial' = FALSE 'cnpj_da_matriz' and
'numero_de_filiais' must be NULL.
How I can do this? Have any way. Can you show me?
Thanks
CREATE TABLE Estabelecimentos
(
CONSTRAINT pk_cnpj
PRIMARY KEY(cnpj),
uf CHAR(2) NOT NULL,
CONSTRAINT fk_uf
FOREIGN KEY(uf)
REFERENCES UnidadesFederativas(uf),
..
filial BIT
NOT NULL,
cnpj_da_matriz INTEGER
NULL,
numero_de_filiais TINYINT
NULL,
..
contrato INTEGER
NOT NULL,
)
GOHow about something like:
Create Table Estabelecimentos
(
PK_CNPJ ? Not Null Primary Key
, UF Char(2) Not Null
, Filial Bit Not Null
, cnpj_da_matriz Int Not Null
, numero_de_filiais TinyInt Null
, contrato Int Not Null
, Constraint Check CK_Validate
Check (Case
When Filial = 1 And 'cnpj_da_matriz Is Not Null And
numero_de_filiais Is Not Null Then 1
When Filial = 0 And 'cnpj_da_matriz Is Null And
numero_de_filiais Is Null Then 1
Else 0
End = 1)
)
HTH
Thomas
"ReTF" <re.tf@.newsgroup.nospam> wrote in message
news:%23TPXj24kFHA.320@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> In my table I have 'filial' attribute(field), and I need check this as fol
ow:
> If 'filial' = TRUE the attributes 'cnpj_da_matriz' and 'numero_de_filiais'
can
> not be NULL else if 'filial' = FALSE 'cnpj_da_matriz' and 'numero_de_filia
is'
> must be NULL.
> How I can do this? Have any way. Can you show me?
> Thanks
> CREATE TABLE Estabelecimentos
> (
> CONSTRAINT pk_cnpj
> PRIMARY KEY(cnpj),
> uf CHAR(2) NOT NULL,
> CONSTRAINT fk_uf
> FOREIGN KEY(uf)
> REFERENCES UnidadesFederativas(uf),
> ...
> filial BIT
> NOT NULL,
> cnpj_da_matriz INTEGER
> NULL,
> numero_de_filiais TINYINT
> NULL,
> ...
> contrato INTEGER
> NOT NULL,
> )
> GO
>|||Hi
You may have to resort to checking this in a trigger!
John
"ReTF" wrote:

> Hi All,
> In my table I have 'filial' attribute(field), and I need check this as
> folow:
> If 'filial' = TRUE the attributes 'cnpj_da_matriz' and 'numero_de_filiais'
> can not be NULL else if 'filial' = FALSE 'cnpj_da_matriz' and
> 'numero_de_filiais' must be NULL.
> How I can do this? Have any way. Can you show me?
> Thanks
> CREATE TABLE Estabelecimentos
> (
> CONSTRAINT pk_cnpj
> PRIMARY KEY(cnpj),
> uf CHAR(2) NOT NULL,
> CONSTRAINT fk_uf
> FOREIGN KEY(uf)
> REFERENCES UnidadesFederativas(uf),
> ...
> filial BIT
> NOT NULL,
> cnpj_da_matriz INTEGER
> NULL,
> numero_de_filiais TINYINT
> NULL,
> ...
> contrato INTEGER
> NOT NULL,
> )
> GO
>
>|||What about creating a trigger to validate the rule?
Example:
create table t1 (
c1 char(1) not null check (c1 in ('t', 'f', 'T', 'F')),
c2 int,
c3 int
)
go
create trigger tr_t1_ins_upd on t1
for insert, update
as
set nocount on
if exists(select * from inserted where c1 = 't' and (c2 is null or c3 is
null))
begin
rollback transaction
raiserror('when c1 = ''t'', c2 or c3 can not be null.', 16, 1)
return
end
if exists(select * from inserted where c1 = 'f' and (c2 is not null or c3 is
not null))
begin
rollback transaction
raiserror('when c1 = ''f'', c2 and c3 must be null.', 16, 1)
return
end
go
insert into t1 values('t', 1, 2)
insert into t1 values('f', null, null)
go
insert into t1 values('t', 3, null)
go
insert into t1 values('f', 4, null)
go
drop table t1
go
AMB
"ReTF" wrote:

> Hi All,
> In my table I have 'filial' attribute(field), and I need check this as
> folow:
> If 'filial' = TRUE the attributes 'cnpj_da_matriz' and 'numero_de_filiais'
> can not be NULL else if 'filial' = FALSE 'cnpj_da_matriz' and
> 'numero_de_filiais' must be NULL.
> How I can do this? Have any way. Can you show me?
> Thanks
> CREATE TABLE Estabelecimentos
> (
> CONSTRAINT pk_cnpj
> PRIMARY KEY(cnpj),
> uf CHAR(2) NOT NULL,
> CONSTRAINT fk_uf
> FOREIGN KEY(uf)
> REFERENCES UnidadesFederativas(uf),
> ...
> filial BIT
> NOT NULL,
> cnpj_da_matriz INTEGER
> NULL,
> numero_de_filiais TINYINT
> NULL,
> ...
> contrato INTEGER
> NOT NULL,
> )
> GO
>
>|||I'd like to add a table constraint like this:
ALTER TABLE [Estabelecimentos] ADD
CONSTRAINT [CK_Estabelecimentos]
CHECK ([filial] = 1 and [cnpj_da_matriz] is not null and
[numero_de_filiais] is not null
OR
[filial] = 0 and [cnpj_da_matriz] is null and
[numero_de_filiais] is null)
GO
Sincerely,
William Wang
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
This posting is provided "AS IS" with no warranties, and confers no rights.

ChartType in RunTime

Could I set up Chart type in run-time. The attempt to set <Type> attribute
inside RDL in the following way:
<Chart Name="1">
...
<Type> = Parameters!ReportChart.Value</Type>
was failed
"Deserialization failed: Requested value =Parameters!ChartType.Value was not
found."
Any suggestion?
Regards
YuriPlease read these postings:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=eda1cbbf-cb32-4ae3-903b-eff73af5cdc6&sloc=en-us
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=a1325500-ca6c-4a71-ad3f-6a59dac96d88&sloc=en-us
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Yuri Belenky" <yurib@.mercatus.no> wrote in message
news:u3HYLMGgEHA.536@.TK2MSFTNGP11.phx.gbl...
> Could I set up Chart type in run-time. The attempt to set <Type> attribute
> inside RDL in the following way:
> <Chart Name="1">
> ...
> <Type> = Parameters!ReportChart.Value</Type>
> was failed
> "Deserialization failed: Requested value =Parameters!ChartType.Value was
not
> found."
> Any suggestion?
> Regards
> Yuri
>|||Thanks a lot.
"Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
news:O3lz4oIgEHA.3932@.TK2MSFTNGP09.phx.gbl...
> Please read these postings:
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=eda1cbbf-cb32-4ae3-903b-eff73af5cdc6&sloc=en-us
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=a1325500-ca6c-4a71-ad3f-6a59dac96d88&sloc=en-us
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "Yuri Belenky" <yurib@.mercatus.no> wrote in message
> news:u3HYLMGgEHA.536@.TK2MSFTNGP11.phx.gbl...
>> Could I set up Chart type in run-time. The attempt to set <Type>
>> attribute
>> inside RDL in the following way:
>> <Chart Name="1">
>> ...
>> <Type> = Parameters!ReportChart.Value</Type>
>> was failed
>> "Deserialization failed: Requested value =Parameters!ChartType.Value was
> not
>> found."
>> Any suggestion?
>> Regards
>> Yuri
>>
>|||Hi Robert,
I have this same question, although when i click the links they dont work'
Any help would be great.
Thanks in Advance
Shea
"Robert Bruckner [MSFT]" wrote:
> Please read these postings:
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=eda1cbbf-cb32-4ae3-903b-eff73af5cdc6&sloc=en-us
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=a1325500-ca6c-4a71-ad3f-6a59dac96d88&sloc=en-us
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Yuri Belenky" <yurib@.mercatus.no> wrote in message
> news:u3HYLMGgEHA.536@.TK2MSFTNGP11.phx.gbl...
> > Could I set up Chart type in run-time. The attempt to set <Type> attribute
> > inside RDL in the following way:
> > <Chart Name="1">
> > ...
> > <Type> = Parameters!ReportChart.Value</Type>
> >
> > was failed
> > "Deserialization failed: Requested value =Parameters!ChartType.Value was
> not
> > found."
> >
> > Any suggestion?
> >
> > Regards
> > Yuri
> >
> >
>
>|||Unfortunately, the news server does not keep an unlimited history of
postings. It seems that both threads have been already removed because they
were too old.
To answer the question: dynamic expression-based chart types are not
available. The closest you can get today is to have multiple charts defined
in your report with different chart types and dynamically hide all of them
(through the Visibility.Hidden property) except for the one you want show.
If you want to change the chart type based on the amount of datapoints, you
might also want to look into using drillthrough actions on the chart. The
main chart would show an aggregated view of the data. Clicking on one of the
data points will then drill through to another report with a detailed view
of the data.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Shea Strickland" <SheaStrickland@.discussions.microsoft.com> wrote in
message news:6A9B2659-3337-4186-B189-CC4FB7CDC7D6@.microsoft.com...
> Hi Robert,
> I have this same question, although when i click the links they dont
work'
> Any help would be great.
> Thanks in Advance
> Shea
> "Robert Bruckner [MSFT]" wrote:
> > Please read these postings:
> >
> >
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=eda1cbbf-cb32-4ae3-903b-eff73af5cdc6&sloc=en-us
> >
> >
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=a1325500-ca6c-4a71-ad3f-6a59dac96d88&sloc=en-us
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> >
> >
> > "Yuri Belenky" <yurib@.mercatus.no> wrote in message
> > news:u3HYLMGgEHA.536@.TK2MSFTNGP11.phx.gbl...
> > > Could I set up Chart type in run-time. The attempt to set <Type>
attribute
> > > inside RDL in the following way:
> > > <Chart Name="1">
> > > ...
> > > <Type> = Parameters!ReportChart.Value</Type>
> > >
> > > was failed
> > > "Deserialization failed: Requested value =Parameters!ChartType.Value
was
> > not
> > > found."
> > >
> > > Any suggestion?
> > >
> > > Regards
> > > Yuri
> > >
> > >
> >
> >
> >|||Robert,
Thanks for the speedy reply, I was heading that way, that post just sounded
like you could do dynamic chart types.
Thanks Again
Shea
"Robert Bruckner [MSFT]" wrote:
> Unfortunately, the news server does not keep an unlimited history of
> postings. It seems that both threads have been already removed because they
> were too old.
> To answer the question: dynamic expression-based chart types are not
> available. The closest you can get today is to have multiple charts defined
> in your report with different chart types and dynamically hide all of them
> (through the Visibility.Hidden property) except for the one you want show.
> If you want to change the chart type based on the amount of datapoints, you
> might also want to look into using drillthrough actions on the chart. The
> main chart would show an aggregated view of the data. Clicking on one of the
> data points will then drill through to another report with a detailed view
> of the data.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Shea Strickland" <SheaStrickland@.discussions.microsoft.com> wrote in
> message news:6A9B2659-3337-4186-B189-CC4FB7CDC7D6@.microsoft.com...
> > Hi Robert,
> >
> > I have this same question, although when i click the links they dont
> work'
> >
> > Any help would be great.
> >
> > Thanks in Advance
> > Shea
> >
> > "Robert Bruckner [MSFT]" wrote:
> >
> > > Please read these postings:
> > >
> > >
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=eda1cbbf-cb32-4ae3-903b-eff73af5cdc6&sloc=en-us
> > >
> > >
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=a1325500-ca6c-4a71-ad3f-6a59dac96d88&sloc=en-us
> > >
> > > --
> > > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> > >
> > >
> > > "Yuri Belenky" <yurib@.mercatus.no> wrote in message
> > > news:u3HYLMGgEHA.536@.TK2MSFTNGP11.phx.gbl...
> > > > Could I set up Chart type in run-time. The attempt to set <Type>
> attribute
> > > > inside RDL in the following way:
> > > > <Chart Name="1">
> > > > ...
> > > > <Type> = Parameters!ReportChart.Value</Type>
> > > >
> > > > was failed
> > > > "Deserialization failed: Requested value =Parameters!ChartType.Value
> was
> > > not
> > > > found."
> > > >
> > > > Any suggestion?
> > > >
> > > > Regards
> > > > Yuri
> > > >
> > > >
> > >
> > >
> > >
>
>