在 SQL 函数/问题中设置变量 [英] Setting variables in SQL functions/probs

查看:24
本文介绍了在 SQL 函数/问题中设置变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个普通的 SQL 过程,它有几个参数.

Assume I have a normal SQL procedure which has a few arguments.

在调试期间,如果我可以为这些参数分配一些值,这样我就可以突出显示 proc 的主体并执行它(而不是手动用值替换变量.

During debugging it would be nice if i could assign some values to these arguments so that I can just highlight the body of the proc and execute it (as opposed to manually replace the variable with values.

有没有办法做到这一点?我试过了:

Is there any way to do this? I tried:

@Date1 datetime,
@Date2 datetime

SET @Date1 = '2012-03-23'

但它不喜欢它??

推荐答案

尝试声明@Date1 日期时间SET @Date1 = '2012-03-23'

您好像遗漏了声明语句.如果它不喜欢2012-03-23"部分,您可能必须将其投射.

Looks like you were missing the declare statement. If it doesn't like the '2012-03-23' part, you may have to cast it.

这篇关于在 SQL 函数/问题中设置变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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