如何将当前数据时间值作为参数传递给过程? [英] how to pass current data time values as parameters to a procedure?

查看:117
本文介绍了如何将当前数据时间值作为参数传递给过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 CORP.USP_INSERT_ASSUEMEDBUSINESSNAMES '  Firebugs',Getdate(),  12 ,GetDate(), 4  11 ,Getdate()



这里是我正在使用的程序,当iam传递参数来测试程序时,我得到语法错误。任何人都可以告诉我如何将当前数据时间传递给存储过程吗?



谢谢&问题

解决方案

你可以在EXEC语句中使用函数 - 它们被视为字符串,括号会混淆并导致错误。字符串替换工作正常:

  DECLARE   @ DATE   DATETIME  = GETDATE(); 
EXEC CORP.USP_INSERT_ASSUEMEDBUSINESSNAMES ' Firebugs' @ DATE 12 @ DATE 4 11 @ DATE


CORP.USP_INSERT_ASSUEMEDBUSINESSNAMES 'Firebugs',Getdate(),12,GetDate(),4,11,Getdate()


here is the procedure iam working with and when iam passing the parameters to test the procedures iam getting syntax error. can any one tell me how to pass current data time to a stored procedure?

thanks & regards

解决方案

You can;t use functions in EXEC statements - they are treated as strings and the brackets will confuse things and cause an error. String substitutions work fine though:

DECLARE @DATE DATETIME = GETDATE();
EXEC CORP.USP_INSERT_ASSUEMEDBUSINESSNAMES 'Firebugs',@DATE,12,@DATE,4,11,@DATE


这篇关于如何将当前数据时间值作为参数传递给过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆