我有一个访问查询,必须将其转换为SQL Server 2012。
查询如下所示我需要将其转换为访问
SELECT col1,
col2, col3,
col4, col5,
Last(col6), Last(col7) ,
last(col8), col9, col10
INTO [Temp 2]
FROM f4
GROUP BY col1, col2, col3,col4, col5, col8, col9
HAVING (col8='529')
AND (trim(col9) in ('S','W'))
AND (trim(col10) in ('301','302','303','305','311','313','319','9101'))
答案 0 :(得分:0)
尝试使用sql server IMPORT工具。这可以帮助您以最少的工作进行转换。您可以在以下位置找到Imports:
Right click on your DB in SQL Server/ Select Tasks/ Select Import Data
答案 1 :(得分:0)
考虑到什么,我会采取刺,并说:
SELECT col1,
col2, col3,
col4, col5,
Max(col6), Max(col7) ,
Max(col8), col9, col10
INTO [Temp 2]
FROM f4
GROUP BY col1, col2, col3,col4, col5, col9, col10
HAVING (col8='529')
AND (ltrim(rtrim(col9)) in ('S','W'))
AND (ltrim(rtrim(col10)) in ('301','302','303','305','311','313','319','9101'))
SQL没有Last或Trim函数,所以我假设你想要Max并且我添加了ltrim(rtrim())功能(它取代了VBA的Trim()功能)。另外,如果你拿最大值的话,我认为你不能分组Col8。