i have problem when i using sql statement in Visual Studio 2005:
for example:
sp_configure 'show advanced options',1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries',1;
GO
RECONFIGURE;
GO
with these statement i have put on separate line to exec, but if i but these statement on separate in VS2005 it is failed, what can i do?
how can i run file .sql from VS2005
HOW?
thanks a lot.
use the following statement to execute the .sql file from your sql server..
USE master
GO
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'show advanced options', 0
GO
Exec XP_CmdShell 'sqlcmd -SWXP-J72MM1S\MSSQL2005 -USA -Psqladmin -i"PATH OF THE .SQL FILE"'
|||it return error:Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.
What can i do? how can i solve?
thanks
|||
Before executing the xp_cmdshell you have to change the server config.
USE master
GO
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'show advanced options', 0
GO
To execute the above batch you shoule be a System Admin.
|||thanks for your answer but i can't get my resultit return 6 rows with output
HResult 0xFFFFFFFF, Level 16, State 1
SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote c
onnections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
NULL
what must i do?|||
The cause may be,
#1. The server is not enabled the Remote Connection (if you are not executing your query from remote server leave this cause and goto #2). To enable the remote login goto Programs -> Microsoft SQL Server 2005 -> Configuration Tools and open the "SQL Server Surface Area Configuration" click the Service & Connections link.
Select the Remote Connections node under the data base engine and check the Local and Remote Connection radio button.
#2. The login you entered is incorrect. don't put more space between your password and -i
sqlcmd -SSERVERNAME -UUSERNAME -PPASSWORD -i"PATH OF THE FILE"
No comments:
Post a Comment