tsql - Automatically Table Insert -


i have problem inserting data table using stored procedure. have use procedures , written other programmer.

with procedure can insert orders database. deliver several attributes procedure , fine. in orders-table there column costumer id.

when insert new row orders table shipping adress overwritten data customer-table. procedure doesn't make this. if write manual insert orders-table shipping adress accepted.

is possible, there hidden procedures wich automatically customer information when inserting new order?

use [ehs] go /****** object:  storedprocedure [dbo].[sp_internetauftrage]    script date: 10/07/2013 12:21:42 ******/ set ansi_nulls on go set quoted_identifier on go  alter procedure [dbo].[sp_internetauftrage] @akcija int = 1, /* many more attributes */       @p6 money = null, @rezultat int = 0 output  begin set nocount on; declare @brojac int set @brojac = 0 declare @typname nvarchar(30) declare @firmc int declare @gespert bit declare @letzeaufnr int declare @letzerechnr int set @gespert=0 select @typname = [name], @letzeaufnr = letzteaufnr, @gespert = gesperrt dbo.t_letzteaufnr typ=@typ , jahr=year(getdate())  set @firmc=(@typ-1)/10 if (@firmc=3) begin     set @firmc=4 end if (@akcija=1)    begin     if (@gespert=0)             begin                 declare @aufnrnew nvarchar(10)                 declare @aufnrn int                 set @aufnrnew =cast(@typ nvarchar(2)) + right(cast(year(getdate()) nvarchar(4)), 2) + right('0000' + cast((@letzeaufnr + 1) nvarchar(10)), 5)                  set @aufnrn = cast(@aufnrnew int)                  print @rechort                  insert dbo.t_internetaufträge (rows) values                                         (values)                  insert dbo.t_internetaufträge_historie (rows) values                                         (values)                  update dbo.t_letzteaufnr set letzteaufnr=(@letzeaufnr+1) typ=@typ , jahr=year(getdate())             -- update dbo.t_letzteaufnr set gesperrt=0 typ=@typ , jahr=year(getdate())                   update t_kunden set firmacust=firmacust |@firmc kunr=@kunr                   set @rezultat=@aufnrn                 return @rezultat     end else begin             set @rezultat=-3 /*gespert*/             return -3         end    end else begin        print 'update'       update dbo.t_internetaufträge set rows=values /* many more */ aufnr = @aufnr       insert dbo.t_internetaufträge_historie (rows) values                                         (values) end set @rezultat = 0  return 0 end 

i found trigger in other table.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -