Windows7 上的 SQL Server 批量插入问题
我有一个使用 SQL Server Express 2005 SP3 的应用程序。该应用程序分发给数百个用户,每个用户都运行 XP。不过,我们公司很快就会迁移到Windows7。我的应用程序在SQL Server中使用批量插入操作,并且在XP中运行良好。然而,在Windows7中,我需要以管理员身份打开SQL Server Management Studio,并执行以下命令才能使批量插入操作正常运行:
EXEC master..sp_addsrvrolemember @loginame = N'BUILTIN\Users', @rolename = N'bulkadmin'
显然,在每个用户的PC上手动执行此操作是不切实际的。因此,我想知道如果用户没有以管理员身份运行我的应用程序,我如何编写此脚本。是否可以在安装过程中在 SQL Server 引导程序包中进行设置?现有的安装情况如何?
I’ve got an application that uses SQL Server Express 2005 SP3. This application is distributed to several hundred users, each of whom is running XP. However, our company will be moving to Windows7 soon. My application uses the bulk insert operation in SQL Server, and it runs fine in XP. However, in Windows7 I need to open SQL Server Management Studio, as Administrator, and execute the following command in order to get the bulk insert operation to run properly:
EXEC master..sp_addsrvrolemember @loginame = N'BUILTIN\Users', @rolename = N'bulkadmin'
Obviously it is impractical to do this manually on each user’s PC. So, I’m wondering how I can script this if the users aren’t running my application as administrator. Is it something that can be set in the SQL Server bootstrap package during installation? What about the existing installs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您安装了数百个 SQL Express?我假设您处于一个可分离的环境中,他们需要他们的待用数据库。
您是否拥有域中所有服务器的管理员帐户?如果是这样,您可以远程运行它 - 只要您可以看到 PC,您就可以从任何地方运行它(假设已设置远程连接)。
您要做的就是使用 SQLCMD 从命令行运行它。
http://msdn.microsoft.com/en-us/library/ms162773。 aspx
您可以在从单个位置安装了 SQL Server 的每台计算机上远程运行相同的命令。
从每个 SQL Server 安装上的管理员域帐户远程运行此命令(只需更改每行的计算机名称)。
如果您多次运行它并不重要,如果该组已经在 BulkAdmins 中,它将不会再次添加。
You have several hundred installations of SQL Express? I assume you are in a detachable environment where they need their to-go database.
Do you have a admin account for all servers on the domain? If so, you can run this remotely - as long as you can see the PC, you can run it from anywhere (assuming remote connections are set up).
All you do is run this from the command line using SQLCMD.
http://msdn.microsoft.com/en-us/library/ms162773.aspx
You run the same command remotely on each machine that has SQL server installed from a single location.
Run this command remotely from a domain account that is admin on each installation of SQL Server (just change the name of the machine for each line).
It does not matter if you run it multiple times, if the group is already in the BulkAdmins it will not add again.