在 Access/SQL Server 中以编程方式导出视图数据
我们有一个连接到 SQL Server 2000 数据库的 Access 应用程序前端。我们希望能够以编程方式将某些视图的结果导出为我们可以使用的任何格式(最好是 Excel,但 CSV/制表符分隔也可以)。到目前为止,我们只是按 F11,打开视图,然后按“文件”->“另存为”,但我们开始获得超过 16,000 个结果,且无法导出。
我想要某种我们可以触发的服务器端存储过程来执行此操作。我知道 sp_makewebtask 过程可以执行此操作,但是它需要服务器上的管理权限,并且由于显而易见的原因,我们无法将其授予每个人。
有什么想法吗?
We have an Access application front-end connected to a SQL Server 2000 database. We would like to be able to programmatically export the results of some views to whatever format we can (ideally Excel, but CSV / tab delimited is fine). Up until now we've just hit F11, opened up the view, and hit File->Save As, but we're starting to get results with more than 16,000 results, which can't be exported.
I'd like some sort of server side stored procedure we can trigger that will do this. I'm aware of the sp_makewebtask procedure that does this, however it requires administrative rights on the server, and for obvious reasons we can't give that to everyone.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能无法授予每个人管理权限,但也许您可以:
创建一个特殊用户,例如“WebTaskUser”,具有读取权限
从所需的视图并执行存储的 sp_makewebtask
程序。您将向一个用户授予权限,而不是向所有人授予权限。
然后创建一个包装存储过程(如下),允许您的用户执行它,同时它包含执行对 sp_makewebtask 过程的特定预定义调用的代码,每个视图一个,仅授予该单个 sp_makewebtask 过程的执行权限。单个用户帐户 - 并非所有管理权限都被授予 - 仅执行 - 只对一个帐户:-)。
根据您的喜好从 SSMS 测试和优化存储过程,
Access-vba,或任何最适合您的内容
当您对过程感到满意时,授予任何进一步的必要
授予您的用户或用户角色的权限,以便他们可以执行它
好吧。
`
`
You might not be able to give everyone administrative rights, but maybe you could:
Create a special user, e.g. 'WebTaskUser', with permissions to read
from the desired views and to execute the sp_makewebtask stored
procedure. You would be giving permissions to one user-not to everyone.
Then create a wrapper stored procedure (below) that allows your users to execute it, while it contains code to execute specific predefined calls to the sp_makewebtask procedure, one per view, granting only execute permissions for that single sp_makewebtask procedure, to one single user account-not all administrative permissions are granted-only execute-only to one account :-).
Test and refine the stored procedure to your liking from SSMS,
Access-vba, or whatever suits you best
When you're happy with the proc, grant any further necessary
permissions to your users or user roles, so they can execute it as
well.
`
`
如果您想在访问中执行所有操作,您可以将视图链接为链接表,然后使用 TransferSpreadsheet 方法将该“表”导出为 csv 文件
编辑:
当您想要在服务器端执行此操作时,请查看
http://www.mssqltips.com/tip.asp?tip=1633
我有以前用过这个,效果很好
If you wanted to do everything in access you could link the view as a linked table and then using the TransferSpreadsheet method you could export that “table” as a csv file
EDIT:
As you want to do it server side check this out
http://www.mssqltips.com/tip.asp?tip=1633
I have used this before and it worked just fine
您可能想看看 SSIS - 它允许创建服务器端包以在服务器端导出数据。
另一种选择是右键单击数据库并运行数据导出向导(下面使用 SSIS)。
另一种选择是创建命令行实用程序 (SQLCMD) 将数据导出到平面文件中。
You may want to look at SSIS - it allows creating server side packages to export data on server side.
Another option is to right-click your database and run through data export wizard (which is using SSIS underneath).
Yet another option is to create command line utility (SQLCMD) to export the data into a flat file.
你用过VB或宏吗?
我刚刚尝试了 26k 行,它工作没有问题
HTH
Have you used VB or Macros?
I just tried it with 26k rows and it worked without a problem
HTH