【发布时间】:2015-01-17 09:02:40
【问题描述】:
我有一个程序:
create proc proc_ins_upd_exp
@id int = 0,
@itemname nvarchar(200),
@price decimal,
@dateofbilling date
as
begin
set nocount on;
if (@id = 0)
insert into exp_tbl (itemname, price, dateofbilling)
values (@itemname, @price, @dateofbilling)
else
update exp_tbl
set itemname = isnull (@itemname, itemname),
price = isnull (@price, price),
dateofbilling = isnull (@dateofbilling , dateofbilling)
where id = @id
set nocount off;
end;
在表exp_tbl中,列dateofbilling的数据类型为date。
如何通过存储过程将dateofbilling 的值作为getdate 插入,或者当该值为NULL 时使用sysdate 更新dateofbilling 的值?
当我尝试执行存储过程时,我得到了错误。
execute proc_ins_upd_exp
@itemname = 'test', @price = 100, @dateofbilling = getdate()
【问题讨论】:
-
哪里出错了??
标签: sql sql-server tsql stored-procedures