Wednesday, March 7, 2012

Ref: Re: Question about stored procedure in SQL Server 2005

Hello all!

I have a (simple) question.

(Sorry for some possible wrong menus-name but I have the italian version of SQL Server 2005 and I'm trying to translate them in best way...)

I want to create a new stored procedure for my database.

I click on "Programmability", then right-click on "Stored procedure" and then click on "New stored procedure".

In the Query Analyzer I write the procedure following the correct syntax, check the sp to be sure that is correct and everything is ok.

The problem is that, when I save the sp, I can create a file with extension .sql, but I don't see the new sp created on the list of stored procedure of the database.....

What's wrong?

Thank you in advance for your help!

Bye

nino

Save is just save your script on your disk for future use (re-usable). But it will not update/save in the database.

You have to execute the script to craete the proc (the button with ! or you can press F5)..

|||

Just Execute created script for your New Stored Procedure.

|||

Just to be exact...

the sp is like this:

Code Snippet

use [db_something]

go

[...]

create procedure [dbo].[updateService]

@.idS int,

@.name varchar(20),

@.var1 varchar(10),

@.var2 int

as

update Tservices

set variable1 = @.var1, variable2 = @.var2

where idService= @.idS and nameX = @.name

go

After this I obviously executed the sp and received "query completed without errors"... But no trace of my sp !!

Bye

Nino

|||

hi,

you just have to run the create script by pressing f5 on the management studio

saving will save the scripts into a physical .sql file but not on the database.

be sure you are running the create script on the appropriate database

to do this issue the use <database> prior to the create proc script

Use northwind

create proc sp1

........

you have probably run the scripts against the master database

regards,

joey

|||

After you run the script execute the following...

Code Snippet

sp_helptext updateService

|||

Thank you all guys!

Now my sp is present.

I hope to contribute in the next not with stupid questions but with good answers!

Bye

Nino

No comments:

Post a Comment