Showing posts with label performed. Show all posts
Showing posts with label performed. Show all posts

Tuesday, March 20, 2012

Check for Null values in Transact Sql

I am using Visual Web Developer Express 2005 and SQL Server Express 2005.

I have set up a trigger that fires when an update has been performed on
a specific table. The trigger checks to see if specific columns have
been updated. If they have, then the trigger code is executed. This part
works fine.

I am now trying to find a way to check if null values exist in either
one of two field from the same table. If either field contains a null
value, then I don't want the trigger code to be executed.

How can I check for null values and skip a block of code within my
Transact Sql trigger.

Thanks....

You can use the IS NULL clause to test a column...

|||

Use something like:

if exists (select * from MyTbl where Col1 is null or Col2 is null)

//do not update

else //update

Monday, March 19, 2012

Check for backups performed

Hi all!
Is there a way to check using transact SQL or any other option that
backup on a database has been performed? Is there any table on the
server that could be queried for successful/unsuccessful backup made?
Or is there a way to get the last date of successful backup made on
the database?
Thanks in advance,
IlyaHi
Use RESTORE VERIFYONLY ... (See BOL for more details)
Nice feature in SQL Server 2005 (You can track backup' percent_complete
,estimated_completion_time )
select top 2 start_time,
percent_complete ,estimated_completion_time
from sys.dm_exec_requests
order by start_time desc
"Ilya" <lentyai@.gmail.com> wrote in message
news:1189513740.265730.67260@.k79g2000hse.googlegroups.com...
> Hi all!
> Is there a way to check using transact SQL or any other option that
> backup on a database has been performed? Is there any table on the
> server that could be queried for successful/unsuccessful backup made?
> Or is there a way to get the last date of successful backup made on
> the database?
> Thanks in advance,
> Ilya
>|||Hi,
The database server mentioned is SQL Server 2000 (SP4).
Thanks,
Ilya|||On Sep 11, 2:31 pm, "Uri Dimant" <u...@.iscar.co.il> wrote:
> Hi
> Use RESTORE VERIFYONLY ... (See BOL for more details)
> Nice feature in SQL Server 2005 (You can track backup' percent_complete
> ,estimated_completion_time )
> select top 2 start_time,
> percent_complete ,estimated_completion_time
> from sys.dm_exec_requests
> order by start_time desc
> "Ilya" <lent...@.gmail.com> wrote in message
> news:1189513740.265730.67260@.k79g2000hse.googlegroups.com...
> > Hi all!
> > Is there a way to check using transact SQL or any other option that
> > backup on a database has been performed? Is there any table on the
> > server that could be queried for successful/unsuccessful backup made?
> > Or is there a way to get the last date of successful backup made on
> > the database?
> > Thanks in advance,
> > Ilya
Hi, Uri!
Thanks for your quick reply.
Found smth myself with the BOL and VERIFYONLY you mentioned.
There is a table called backupset in msdb database. There are a plenty
of fields and backup_finish_date & database_name as well. These two
give me what I need (the date of the last backup made on the
database).
Then the following SQL gives me what I need:
SELECT TOP 1 backup_finish_date
FROM msdb..backupset
WHERE database_name = '<The name of the database>'
ORDER BY backup_finish_date DESC
Thanks again,
Ilya

Check Database Operation

Hi,
I want to check that which operation like Insert, Update or Delete is
performed on the table in a trigger written for all the these opertaions.
Is there is any function from which I can know this?
Thanks.The only way you can tell in a trigger is the presence or absence of rows in
the inserted and deleted table:
1. No rows in either table - nothing was changed
2. Rows in inserted , none in deleted - Insert
3. Rows in deleted , non in inserted - Delete
4. Rows in both - Update
--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Syed Zulfiqar" <zulfiqar_syed@.hotmail.com> wrote in message
news:uzu3YIgHEHA.548@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I want to check that which operation like Insert, Update or Delete is
> performed on the table in a trigger written for all the these opertaions.
> Is there is any function from which I can know this?
> Thanks.
>