Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a table [dbo].[CustomerDetails]

having columns like Id, Name, PhoneNo, Email, Address, City, State
i created executed sp in db level and table level.

But its returning
All columns: Id,Name,Phone,Email,Address,City,State
I need to get only if any update or insert or delete happen only for Email and City
how to mention only particular column

Thanks in Advance.

What I have tried:

What I have tried:

Exec Sys.sp_cdc_enable_db
EXEC sys.sp_cdc_enable_table
@source_schema=N'dbo',
@source_name=N'CustomerDetail',
@role_name=null
Posted
Updated 24-Jan-18 2:17am
Comments
[no name] 24-Jan-18 7:28am    
Can you please frame your question again?

1 solution

In your triggers join the Inserted table to your CustomerDetails table and compare the values. If they are different then you need to do your actions.

Note that there is no concept of "delete" at the column level - that would be an update to a blank or a null value. Same with insert. The entire row is inserted, any movement of the column from a null to a non-null value is an update.

There is an example of something similar here - SQL Server Trigger After Update for a Specific Value[^]
 
Share this answer
 
Comments
Salt Pepper 24-Jan-18 9:03am    
ya but its trigger i have to use CDC- change data capture
CHill60 24-Jan-18 18:38pm    
I have no idea what your comment means! We had the same problem with your question.
Can you explain the problem clearly?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900