excel中的sql查询
我有一个查询,其中的参数是从 Excel 工作表中的 2 个单元格(除了查询所在的单元格)中获取的。所以,问题是我打开数据连接来更改查询,因为它返回的值是错误的,并替换了查询。现在我执行以下操作:
DECLARE @year AS int
DECLARE @month AS int
DECLARE @date AS datetime
SET @year = ?
SET @month = ?
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ?) + '-' + RIGHT( '0' + CONVERT( varchar(2), ?), 2 ) + '-01' ) )
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ? ) + '-' + RIGHT( '0' + CONVERT( varchar(2), ? ), 2 ) + '-01' ) )
然后我希望参数按钮会突出显示,以便我对它们进行服装化,什么也不做。 是声明本身有问题吗?
后来,在查询中,我做了一些事情,例如 date >=
DECLARE @year AS int
DECLARE @month AS int
DECLARE @date AS datetime
SET @year = ?
SET @month = ?
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ?) + '-' + RIGHT( '0' + CONVERT( varchar(2), ?), 2 ) + '-01' ) )
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ? ) + '-' + RIGHT( '0' + CONVERT( varchar(2), ? ), 2 ) + '-01' ) )
这些是参数。 这个日期声明有问题吗?基本上我有2个日期,closure_date和begin_date,它们都接受年份和月份。这些是参数。我应该如何“查询”他们?
I have this query where the parameters are being fetched from 2 cells in an excell sheet, other that the one where the query is. so, the problem is i opened the data connection to change the query, since the values it's returning are wrong, and repplaced the query. now i do the following:
DECLARE @year AS int
DECLARE @month AS int
DECLARE @date AS datetime
SET @year = ?
SET @month = ?
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ?) + '-' + RIGHT( '0' + CONVERT( varchar(2), ?), 2 ) + '-01' ) )
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ? ) + '-' + RIGHT( '0' + CONVERT( varchar(2), ? ), 2 ) + '-01' ) )
and then i expect fo the parameter button to be highlited for me to costumize them and nothing.
Is a problem with the declaration itself?
Later on, on the query, i do things such date >=
DECLARE @year AS int
DECLARE @month AS int
DECLARE @date AS datetime
SET @year = ?
SET @month = ?
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ?) + '-' + RIGHT( '0' + CONVERT( varchar(2), ?), 2 ) + '-01' ) )
SET @date = DATEADD( month, 1, CONVERT( datetime, CONVERT( varchar(4), ? ) + '-' + RIGHT( '0' + CONVERT( varchar(2), ? ), 2 ) + '-01' ) )
Those are the parameters.
Is there somthing wrong with this date declaration? Basically i have 2 dates, closure_date and begin_date and both of them accept year and month. Those are the parameters. How should i 'query' for them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说看起来
不对 - 我不是 100% 确定,但这可能是问题所在......
the
looks wrong to me - I'm not 100% sure but this might be the problem...