Monday, June 3, 2013

[T-SQL] triggers

[T-SQL] triggers


triggers

Posted: 02 Jun 2013 09:38 PM PDT

Hello all, I've created a trigger that I'm having a bit of a problem with.After a user completes a warrantly form online, I do a lookup against an internal table to see if they are a registered installer, and mark them as so... [code="other"]ALTER TRIGGER [dbo].[TRIG_Update_Installer] ON [dbo].[tbl_warranties] AFTER insertAS BEGIN update tbl_Warranties set siteID = 'O' where ID in ( SELECT dbo.tbl_warranties.ID FROM dbo.Tbl_InstallersList INNER JOIN dbo.tbl_warranties ON dbo.Tbl_InstallersList.Gas_id = dbo.tbl_warranties.business_gsn WHERE (dbo.tbl_warranties.business_gsn IS NOT NULL) AND (LEN(dbo.tbl_warranties.business_gsn) > 0 and datePickup is null) ) END[/code]If I run the code within the BEGIN, it works perfectly.. I just can't get it to run from the trigger after the record has been inserted :(I've tried 'on insert' and 'after insert'Any help would be most appreaciated..Many thanksDave

(SQL) Excel file has bigger size using OPENQUERY to update it

Posted: 02 Jun 2013 10:13 PM PDT

Maybe the solution can be so easy but I can't find it so I write here for some help.We have this sql function:CREATE FUNCTION [dbo].[updateExcel]( -- Add the parameters for the function here @cell VARCHAR(4), @description VARCHAR(200))RETURNS BITASBEGIN DECLARE @sql NVARCHAR(1000) SET @sql = 'UPDATE openquery(LinkedServer2ExcelFile, ''SELECT * FROM [Sheet1$'+@cell+':'+@cell+']'') set F1 = '''+@description+'''' --PRINT @sql EXEC sp_executesql @sql RETURN 0ENDthat we use to update some excel fileEXEC @Result = updateExcel 'somecell', 'somevalue'The problem is that after this update the excel has a bigger size. But when we open it and save it again, the file's size get normal againI hope to find here some answers ...Thanx !!!

No comments:

Post a Comment

Search This Blog