Find Records in SQL SERVER Table and Do some Execution
Example I:
Try to find records or data in table with table column field condition, if exists, do something, like below:
IF (exists(select * from T_CurrentSummary(nolock) where revenue=0))
Begin
Execute DatabaseName.[dbo].[T_Reinitialise]
End
Example II:
Try to find records or data in table, if not, do something, like below:
If ( NOT EXISTS(Select top 1 * from T_CurrentSummary(nolock)))
Begin
Execute DatabaseName.[dbo].[T_Reinitialise]
WAITFOR DELAY '00:00:01'
Print 'Hi Reinitilaised'
End
Example III:
Try to find records or data in table, if not, do not do anything, like below:
select * from T_CurrentSummary(nolock)
If @@rowcount =0 Return -- The execution will return without doing further.
No comments:
Post a Comment