Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
srisha
Starting Member
38 Posts |
Posted - 2013-05-23 : 05:32:09
|
ALTER TRIGGER [dbo].[trigg1] ON [dbo].[OEORDH] AFTER INSERTAS BEGINUpdate OEORDHO SEt oeordho.VALUE =Rtrim(inserted.LOCATION) + (Select isnull(MAX(convert (int,(SUBSTRING(OEORDHO.VALUE,LEN(inserted.LOCATION)+1,LEN(OEORDHO.VALUE))))),0) + 1 From OEORDHO Where LEN(OEORDHO.VALUE)=LEN(inserted.LOCATION) and ISNUMERIC(SUBSTRING(OEORDHO.VALUE,4,LEN(OEORDHO.VALUE))) = 1 AND OPTFIELD='INVNO' AND LEFT(OEORDHO.VALUE,LEN(Rtrim(inserted.LOCATION)))=Rtrim(inserted.LOCATION)) From inserted Where OEORDHO.ORDUNIQ=inserted.ORDUNIQ AND OPTFIELD='INVNO'ENDMultiple columns are specified in an aggregated expression containing an outer reference. If an expression being aggregated contains an outer reference, then that outer reference must be the only column referenced in the expression. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-23 : 05:34:14
|
The given trigger code doesnt make much sense to me. You dont even have INSERTED table referred in query. Can i ask what you're trying to implement by the above code?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
srisha
Starting Member
38 Posts |
Posted - 2013-05-23 : 05:38:51
|
To generate different document series on the basis of location chosen at different transaction screens .This is planned by using the combination of ‘Location’ + Document Number (number with / without prefix).------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs[/quote] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-23 : 05:40:22
|
hmm...whats the purpose of doing this in a trigger then? Why not make the VALUE as a computed column instead?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
srisha
Starting Member
38 Posts |
Posted - 2013-05-23 : 07:31:40
|
value is the one field name . Location wise record numberquote: Originally posted by visakh16 hmm...whats the purpose of doing this in a trigger then? Why not make the VALUE as a computed column instead?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
|
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-23 : 07:36:01
|
ok...but didnt understand whats the problem in making it computed still?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|