snippetMinor
How to modify a stored procedure using SQLCMD for MS SQL?
Viewed 0 times
storedsqlprocedureusingsqlcmdhowformodify
Problem
Suppose a stored procedure as follows have been created using the Microsoft SQL Management Studio.
Is it possible to modify a stored procedure using
use testbase
go
create procedure testtable_pricesmaller
@pricelimit money
as
select * from testtable where price = @pricelimit;
goIs it possible to modify a stored procedure using
SQLCMD for MS SQL?Solution
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:
Alternatively if you have an existing script file that has the command you want to run you could use the
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.
sqlcmd -E -S computer\instance -d database
alter procedure testtable_pricesmaller
@pricelimit money
as
select * from testtable where price = @pricelimit;
goAlternatively 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.sqlHere 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.
Code Snippets
sqlcmd -E -S computer\instance -d database
alter procedure testtable_pricesmaller
@pricelimit money
as
select * from testtable where price = @pricelimit;
gosqlcmd -E -S computer\instance -d database -i file.sqlContext
StackExchange Database Administrators Q#23992, answer score: 5
Revisions (0)
No revisions yet.