Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

Here is some more information on the sqlcmd utility that you should find helpful:

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

I hope this helps you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.