Thursday, June 20, 2013

Conditional trigger in SQL Server

Create TRIGGER trg_Student_Monitoring ON Categories AFTER UPDATE AS

IF (select COUNT(name) from students s, deleted d where s.studentId = d.studentID and s.categoryId = 4 )>=1
Begin
      INSERT INTO Students_Temp(StudentID, StudentNAME,  StudentCategory)
      SELECT  I.StudentID, I.StudentNAME,  I.StudentCategory FROM INSERTED I
End

Unable to see triggers in SSMS


Unable to find triggers in SSMS ?

Below query helps to identify whether triggers are there or not 

SELECT so.name, st.name, st.type FROM sys.triggers st LEFT OUTER join sys.objects so
ON st.parent_id = so.object_id AND st.is_ms_shipped =0 

Later we need to expand Databases - Tables - Triggers (you will be able to see triggers in this path)

 

Friday, June 7, 2013

Msg 952, Level 16, State 1, Line 1 Database is in transition offline database to online


I got the below error message when i am trying to bring the offline database to online.

Msg 952, Level 16, State 1, Line 1 Database 'xxxxxxx' is in transition.

Below solution worked for me, It may varies from environment to environment

Try to access the database from SSMS, If it gives same error message then restart the SSMS,

Sometimes restart SSMS will fix the issue, If not issue the below comand

select spid, db_name(dbid) from master..sysprocesses where dbid = dbid('db_name')

Verify are there any spids which is trying to access the database,

Issue kill on that SPID, then database will become offline

bring the database online, it works for me

Monday, June 3, 2013

The IP Address xx.xx.xx.xx is already in use. To continue, specify a different IP address In SQL Server 2008 cluster installation


The IP Address xx.xx.xx.xx is already in use. To continue, specify a different IP address.

We may encounter the above error message while performing SQL Server Cluster Installation.

Workaround

1. You may need to remove ARP address and then restart the cluster installation.

2. If deleting ARP doesn't fix the issue, then you may continue with the DHCP and complete the installation, later you can add static DNS entries by getting the DHCP IP address to the SQL Server network name from failover cluster manager.