Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

xp_cmdshell vs. stored proc

$
0
0
Hi All, Due to our 3 month, year end change freeze, we are not allowed to create new stored procedures at the moment on a production database. We have done all the development work for new features on the production site and would like to start running them as soon as possible. However due to the change freeze till end January, the only way we can reliable run the scripts is by running the *.sql file using parameters through xp_cmdshell. I have examined the execution plans and everything looks the same (development proc vs xp_cmdshell execution), we do however see a minor decrease in performance when using the xp_cmdshell method. We can live with that however for the course of the change freeze. Are there any other down sides to using this method that we might have over looked and are the execution plans cached when we use the xp_cmdshell method ? Here is a sample of how we would execute the script till February using XP_cmdshell [b]DECLARE @SQLCMD VARCHAR(8000) ----CLIENTASET @SQLCMD = 'sqlcmd -S SERVER\MSSQL2014DEV -d CLINETA_Database -i \\servername\scripts\script1.sql -v db="TargetDatabase" destination="OutputTable" schema="CUSTOM" source="SourceTable"'EXECUTE xp_cmdshell @SQLCMD;[/b]This is how the stored proc kicks off [b]EXEC dbo.CLIENTA_NewProc@db = 'TargetDatabase', @destination = 'OutputTable',@schema = 'CUSTOM',@source = 'SourceTable'[/b]Thanks in advance

Viewing all articles
Browse latest Browse all 3145

Trending Articles