.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Create TRIGGERS in sql 2008

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :Sql Server


I am new to SQL 2008.

For the past 3 days, I have been battling with TRIGGERS.

In my database, I have 2 tables : one is called "Details" (which includes : detailsid,personid,surname, firstname).

The second table is "Mainaddress" (addressid, personid, street, city).

These 2 tables share only one common attribute : personid

Next, I created a VIEW for these 2 tables, as follows :

SELECT dbo.mainaddress.street, dbo.mainaddress.city

FROM dbo.mainaddress

INNER JOIN dbo.Details ON dbo.mainaddress.personid = dbo.Details.personid

But, as we all know, it is not possible to manipulate more than one base table when using VIEWS.

To solve this problem, I decided to create TRIGGERS. I created 3 triggers : one each for INSERT, UPDATE and DELETE.

But, for some reason, I keep getting the error :

INVALID COLUMN NAME ("column name")

I have searched far and wide for a solution : forums, Google, etc, but without success.

For example : here is my INSERT trigger.


create trigger

View Complete Post

More Related Resource Links

Create WAP in VS 2008


Hi all, i plan to create a WAP site with VS 2008 by New 1 normal web application project, ist doable?

are the things i should take care about is:

- make sure the header of html is xhtml?

- no using session to pass info?


Besides, is all the C# code like that call database will work like normal asp.net?



Can't Create ODBC to Local SQL Server Express 2008

Hello. I have SQL Server Express 2008 SP1 LOCALLY on my Windows XP Professional SP3 box. I have databases already created in Access 2007 that I imported into SQL. Now I want to keep the front end Access forms for data entry but have them connect to the databases in SQL. What I can't seem to do is connect from Access to the SQL db's because I can't create the ODBC connection. When I try to connect, I get the following two 'Connection failed' errors: 1. SQLState: '08001' SQL Server Error: 10061 [Microsoft][SQL Server Native Client 10.0]TCP Provider: No connection could be made because the target machine actively refused it. 2. SQLState: 'HYT00' SQL Server Error: 0 [Microsoft][SQL Server Native Client 10.0]Login timeout expired Additionally, this information may help. 1. Windows firewall is turned off. 2. In SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for SQLEXPRESS, Shared Memory, Named Pipes and TCP/IP are all 'Enabled'. The order is Shared Memory (1), Named Pipes (2) and TCP/IP (3). 3. In SQL Server Configuration Manager > SQL Native Client 10.0 Configuration > Client Protocols, the above three are also 'Enabled'. The order is Shared Memory (1), Named Pipes (2) and TCP/IP (3). Double-clicking TCP/IP tells me that the default port is 1433. 4. Running "netstat -ano", I see no entries for [myIPaddress]:1433.

Cannot create maintenance plan in SQL 2008 SP1

I receive the following error trying to create a maintenance plan in SQL 2008 SP1 on a Windows 2008/R2 server: The action you attempted to perform on a remote instance of SQL Server has failed because the action requires a SQL Server component that is not installed on the remote computer. To proceed, install Microsoft SQL Server Management Tools on the remote computer, and then try again. The components that installed are Database Engine Services, Reporting Services, Client Tools Connectivity, Management Tools Basic/Complete, and SQL Client Connectivity SDK.  I have another independent SQL 2008 SP1 server running on the same platform with the same features installed and I have no problem creating maintenance plans there.  However, it does have IIS as it was upgraded from a SQL 2005 server which required IIS for reporting services while SQL 2008 does not. I'm familiar with http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/06c80a78-a877-4a48-a032-b0aef78a598c but that doesn't seem to apply as this was a new SQL 2008 installation on a freshly installed OS.  I've seen several other postings of this on the web but they all appear specific to SQL 2005. What else could be missing? Thanks.

Unable to create Web Folders in Windows Server 2008 R2

Hi, We are unable to create web folder from a Windows Server 2008 R2 system as we do in Windows XP. The web url cannot be identified. The web url is an oracle repository application built in 32-bit OS and now we need this to be added in Windows Server 2008 R2 machine. Kindly help.  

Cannot Create Database Diagrams - SQL Server 2008 Management Studio

I cannot create a database diagram with my client-side SQL Server Management Studio.  I can do this if I am on the actual db server itself.  Please help.

(SQL Server 2008) Exporting entire databases to SQL CREATE/INSERT statements

Hi All, I'm looking for a way to export SQL Server 2008 (Express or otherwise) databases to CREATE/INSERT statements.  I've seen a million threads (give or take) with instructions for creating large (often illegible) TSQL scripts for the task.  However, I'm hoping that this isn't the only way by which to do it.  I have need to regularly back up the data from existing MS SQL Server DBs (which are used by some of our standard apps) to various other MySQL and PostgreSQL databases (which are used by PHP and Rails web front ends).  I need to export them from MS SQL Server 2008 to a general format (i.e. INSERT statements) and perform regex edits on the file as necessary. FYI, I've written a few applications that connect to the various DBs over ODBC, etc. and transfer the data row by row.  You can image how painful this process is... I realize that there are many tools that do this.  However, most of them approach the issue from the standpoint of migration, and not that of regularly scheduled backups.  Also, this tool will need to eventually be distributed so having to purchase a license for the migration app for each person/group simply isn't feasible. Anyway, if you guys have a quality, straightforward solution to this issue, it would certainly be appreciated. Best.

please help me to create database in sql server 2008

hi,    i am new to asp.net. i like to learn asp.net and c#. when i try to connect to sql server, it asks server name. i don't know server name and it asks database name also. how to create database and where can i access like phpmyadmin. in phpmyadmin i can create database and tables. i am new to this. please help me.thanks.  

How to create a SSIS package to import records form SQl Server 2008 tables to text files

I am a newbie to SSIS and would like to create a package to accomplish the task referenced in the above title. Will appreciate any links and pointers in the right direction.   Thanksakoranteng

How to create Range bar chart i n SSRS 2008

  Hi How to create Range bar chart i n SSRS 2008 amit

Need to create Chart in SSRS 2008

0 Hi Sorna, I want data in this format as below   | |                                           b________                 b________ |                   a_____                               a________ |_____________________________________________ 0      1           2      3              6               7                  24 time   X- axis -- Time Y - Stand jsut for single name.showing dotted but consider as simple y axis. Name A suppose to perform two work a,b and he perform a in 2Am to 3Am while b in 6 Am to 7 Am,now i want to create the bar chart as above please suggest how to do.   I have seen this url ::http://www.sqlservercentral.com/arti

Create new instance of sql 2008 R2 server

Is there a way to create a instace of sql server just using my pc name? Currently sql uses 'machine name\instance name'

SQL SERVER 2008 Create Maintenance Plans encounter General Access Denied error


After I clicked New Maintenance Plans and filled in <Maintenance Plans Name>, an error appeared like below: General access denied error, my account is already sysadmin and public, and agent service has started.


TITLE: Microsoft SQL Server Management Studio


General access denied error


General access denied error



Adding triggers to a Merge Replicated published article in SQL Server 2008


Currently running merge replication on SQL Server 2008 10.0.1600 and I have a few questions around the correct procedures for adding and modifying triggers on published articles.  I've searched through the MSDN site and googled this but have not found any definitive information on correct procecdures.

1) When a new trigger is added to a published table do we just have to rerun the snapshot and then re-syncy the subscribers?  Just adding them does not seem to replicate them to subscribers.

2) When an existing trigger is modified should ALTER TRIGGER be used or should the trigger be dropped and then re-added?


How to Create SPC Histogram chart in SSRS 2008


Hi All,

I need to create SPC Histogram chart in SSRS 2008 to represent Cp, Cpk etc. i can calculate all this Cp, Cpk but not getting how to represent as a chart in SSRS 2008. I know there is no readymate  template availavle in SSRS for SPC but is there any other way to draw histogram chart ?

You can see the SPC histogram chart example on this link : http://www.qimacros.com/qiwizard/process-capability.html

Any help in this regard will be highly appreciated.

Thanks & Regards

Nipendra Garg

how to create crystalreport in vb.net 2008 from 3 diffrent msaccess table?


Its a Windows Application

I Want to Create a CrystalReport from 3 Table in a single .mdb file & i want to display 1st table at once & 2nd table having multiple records & 3rd table also having multiple record which is related to 1st table

eg. i have 1st table as bill, 2nd table as material & 3rd table as payment. Now all 3 table has bill_id common field so i want to display record for only bill_id which i have selected.

How to Do Its Urgent? pls help me

Thanks in Advance

SQL Server 2008 Merge Replication article triggers not replicating


Currently running merge replication on SQL Server 2008 10.0.1600 and having issues with adding and modifying triggers on published articles.  I've searched through the MSDN site and googled it but have not found any definitive information on correct procecdures.

We have a replicated table that had 1 trigger on it when it was added to the publication.  That trigger was replicated.  We have since added a 2nd trigger to the table and it is not being replicated to our other server.  I've checked the Article Properties and Copy User Triggers is set to TRUE.  The only difference is the new trigger has NOT FOR REPLICATION in it, but I thought that would only keep it from being executed if a row is effected by the MERGE process.

We have rerun the snapshot and are syncing continuosly and the trigger does not replicate.  Do I have to drop the tablefrom the publication and then re-add it?  Am I missing something? 


how to create resource file in VB.NET (VS 2008)


Hi all,


   I want to create and use resource file in my application (VB.NET 2008). Can i use .resx file or should i convert it into .resources file? please tel me the steps to create and use resource file in VB.NET with sample code.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend