View Single Post
Old 17.01.2007, 09:05   #5
mono
Архивный участник
 
Join Date: Dec 2006
Posts: 16
Default

ALTER PROCEDURE dbo.lin_SetLastTaxUpdate
(
@income varchar(100),
@tax varchar(100),
@manor varchar(100)
)
AS

declare @income_ datetime
declare @tax_ datetime
declare @manor_ datetime

set @income =left(@income,5) + cast((cast(replace(substring(@income,6,2),'-','') as int) + 1) as varchar) + substring(@income, charindex ('-', @income, 6),100)
set @tax =left(@tax,5) + cast((cast(replace(substring(@tax,6,2),'-','') as int) + 1) as varchar) + substring(@tax, charindex ('-', @tax, 6),100)
set @manor =left(@manor,5) + cast((cast(replace(substring(@manor,6,2),'-','') as int) + 1) as varchar) + substring(@tax, charindex ('-', @tax, 6),100)

set @income_ = convert(datetime, @income)
set @tax_ = convert(datetime, @tax)
set @manor_ = convert(datetime, @manor)


SET NOCOUNT ON
IF EXISTS(SELECT * FROM castle_tax)
BEGIN
UPDATE castle_tax SET income_update = @income_, tax_change = @tax_, manor_reset = @manor_
END
ELSE
BEGIN
INSERT INTO castle_tax VALUES
( @income_, @tax_, @manor_)

END
mono is offline