Toad 和 SQL Server 2005
where a.system_nr =''''5300'''' and
a.external_status_cd = '''''''' and
a.cust_acct_id = b.rel_cust_acct_id and
b.cust_acct_id = c.cust_acct_id and
c.cust_acct_id = d.cust_acct_id and
d.acct_status_cd = ''''OPEN'''' and
d.time_mnth_gen_id =''''' + @BegDate + ''''' and
a.cust_acct_id = e.cust_acct_id and
e.tran_dt >=''''' + @BegDate + ''''' and
e.tran_dt<=''''' + @EndDate + ''''' and
d.portfolio_cd = ''''HEQ'''' and
a.time_mnth_gen_id =''''' + @BegDate + ''''' '')'
这是已经写好的where条件,我需要进行更改。
您能告诉我为什么他们使用 '''''+@begdate'''''
吗?我可以使用'+Bedate'
吗? 我的意思是为什么他们每一边都使用 '''''
?
where a.system_nr =''''5300'''' and
a.external_status_cd = '''''''' and
a.cust_acct_id = b.rel_cust_acct_id and
b.cust_acct_id = c.cust_acct_id and
c.cust_acct_id = d.cust_acct_id and
d.acct_status_cd = ''''OPEN'''' and
d.time_mnth_gen_id =''''' + @BegDate + ''''' and
a.cust_acct_id = e.cust_acct_id and
e.tran_dt >=''''' + @BegDate + ''''' and
e.tran_dt<=''''' + @EndDate + ''''' and
d.portfolio_cd = ''''HEQ'''' and
a.time_mnth_gen_id =''''' + @BegDate + ''''' '')'
Here is the where condition which is already written and I need to make changes.
Can you please tell me why they are using '''''+@begdate'''''
? Can i use '+Bedate'
?
I mean why they are using '''''
each side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 SQL Server 中尝试此操作:
您会注意到该项给出:
在 SQL Server 中
''
将等同于单引号字符,因此上面的行是Try this in SQL Server:
You notice that item gives:
In SQL Server
''
will equate to a single quote character, so the above line is在没有看到 SQL 的其余部分的情况下,我的猜测是:
@BegDate
是一个变量,并且语句以单引号结尾,引号不应该只是
'+BegDate'
因为它是一个变量,并且剥离@
会导致它被评估为一个字段。如果您只是想减少单引号的数量,我想原作者将它们放在那里是有原因的。您可以使用原始单引号运行查询,然后使用减少的单引号再次运行查询,看看是否获得相同的结果集。
Without seeing the rest of the SQL, my guesses would be:
@BegDate
is a variable and you have the statement ending with a single quoteYou should not be able to just
'+BegDate'
because it's a variable and stripping the@
would cause it to be evaluated as a field.If you meant to just reduce the number of single quotes, I would imagine the original author put them there for a reason. You can run the query with the original single quotes and again with the reduced single quotes and see if you get the same result set.