Posts

Showing posts from May, 2019

Index on view

Let's say if we create index on a view  and if we alter the view then the index gets dropped and again we have to create a index on the view

knowing the server exist or not

Run the command in the command prompt : ping servername -t to know the details

Adding the primary key for two columns

CREATE   TABLE  Persons (     ID int  NOT   NULL ,     LastName varchar( 255 )  NOT   NULL ,     FirstName varchar( 255 ),     Age int, CONSTRAINT  PK_Person  PRIMARY   KEY  (ID,LastName)

Bidirectional Trigger ( Insert in one table and reflected in another table and vice versa)

Concept : Enabling the trigger on first table and enabling the CT on other table to get the table data inserted. /* On first table */     CREATE TRIGGER [dbo].[InsertReportedsoftwareimages]    ON [dbo].[ReportedSoftwareImages]    AFTER INSERT    AS    IF @@ROWCOUNT > 0    BEGIN TRY;    SET NOCOUNT ON ;        -- dbo.SoftwareBuildRecords --------------    MERGE dbo.SoftwareBuildRecords AS tgt    USING (SELECT t.[Changerequestid],t.[softwareimageBuild],t.[softwareimagename], t.IsFoundOnSoftwareImage    FROM INSERTED t inner join    dbo.ChangeRequests_ProblemReport problemReports    ON t.ChangeRequestId = problemReports.Id and t.IsFoundOnSoftwareImage=1) as src    ON ( tgt.[Changerequestid] = src.[Changerequestid]    and tgt.softwareimagename = src.softwareimagename     )    WHEN NO...