# How to modify a stored procedure using SQLCMD for MS SQL?

Suppose a stored procedure as follows have been created using the Microsoft SQL Management Studio.

use testbase
go
create procedure testtable_pricesmaller
@pricelimit money
as
select * from testtable where price = @pricelimit;
go


Is it possible to modify a stored procedure using SQLCMD for MS SQL?

-

Assuming that you have the permission to do so then there should be no reason why you could not. The following example assumes that you are using Windows Authentication:

sqlcmd -E -S computer\instance -d database

alter procedure testtable_pricesmaller
@pricelimit money
as
select * from testtable where price = @pricelimit;
go


Alternatively if you have an existing script file that has the command you want to run you could use the -i option to run that file:

sqlcmd -E -S computer\instance -d database -i file.sql


http://msdn.microsoft.com/en-us/library/ms180944.aspx

I hope this helps you.

-