mitra- Posted October 23, 2007 at 11:05 AM Report Share #142362 Posted October 23, 2007 at 11:05 AM Boas! Alguém me pode dar umas luzes (exemplos de código) ou links para a criação de Triggers em T-SQL (SQL Server 2000) para manter a integridade nas referências de chaves estrangeiras? Tenho umas tabelas numa DB que precisam de referenciar chaves em tabelas de outra DB. Se estivessem na mesma DB bastava criar uma CONSTRAINT para FOREIGN KEY REFERENCE, mas como não posso fazer Cross Database References tenho de recorrer a Triggers. Agredeço desde já qualquer ajuda! 😉 Link to comment Share on other sites More sharing options...
Hipnoted Posted October 23, 2007 at 04:16 PM Report Share #142427 Posted October 23, 2007 at 04:16 PM Tens nesta secção alguns exemplos sobre como se cria um trigger em SQL Server. Por exemplo este aqui: http://www.portugal-a-programar.pt/index.php?showtopic=12137 Na documentação da Microsoft também mostra, e mesmo na documentação que deves ter no teu PC quando instalas o SQL Server. "Nunca discutas com um idiota. Eles arrastam-te até ao seu nível e depois ganham-te em experiência" Link to comment Share on other sites More sharing options...
freaklori Posted October 24, 2007 at 04:38 PM Report Share #142661 Posted October 24, 2007 at 04:38 PM Aproveitando esta treadh tenho uma duvida... Criei um trigger relacionado com um insert numa tabela, mas sempre que tento fazer um insert da me o seguinte erro.. quer no VB.net ou no SQLServer A .NET Framework error occurred during execution of user-defined routine or aggregate "T": System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. System.Security.SecurityException: at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.PermissionSet.Demand() at System.Data.Common.DbConnectionOptions.DemandPermission() at System.Data.SqlClient.SqlConnection.PermissionDemand() at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at CLR.Texto_Em_Palavras() . The statement has been terminated. Ja ando de volta disto algum tempo.. se alguem me puder ajudar!! Cumps FAÇO TUDO COM DUAS LINHAS DE CÓDIGO; Link to comment Share on other sites More sharing options...
Hipnoted Posted October 24, 2007 at 05:35 PM Report Share #142679 Posted October 24, 2007 at 05:35 PM Aproveitando esta treadh tenho uma duvida... Criei um trigger relacionado com um insert numa tabela, mas sempre que tento fazer um insert da me o seguinte erro.. quer no VB.net ou no SQLServer A .NET Framework error occurred during execution of user-defined routine or aggregate "T": System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. System.Security.SecurityException: at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.PermissionSet.Demand() at System.Data.Common.DbConnectionOptions.DemandPermission() at System.Data.SqlClient.SqlConnection.PermissionDemand() at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at CLR.Texto_Em_Palavras() . The statement has been terminated. Ja ando de volta disto algum tempo.. se alguem me puder ajudar!! Cumps Abre um tópico com a tua dúvida, e coloca o trigger sff. "Nunca discutas com um idiota. Eles arrastam-te até ao seu nível e depois ganham-te em experiência" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now