I've written a few SQL stored procedures in a text editor. But how do I actually "store" them in (add them to?) a database using SQL Server 2008 Management Studio Express? I've tried to research this topic in Management Studio's onboard Help, but apparently Help assumes I know more about the subject than I actually do, because I don't even see the relevance of the answers I'm getting to my questions. Any help would be appreciated, including pointing me to a good SQL tutorial that assumes the reader knows nothing, yet teaches more than the bare-bones minimum.

in management studio you can use object explorer, open your database (expand), go to programmability right click on stored procedures and click new stored procedure

you can also do it manually by this

create procedure ProcedureName
as
BEGIN
... do the work here
END

dickersonka:

Thanks for your help.

One question: don't I have to associate a procedure with a given table? Otherwise, how will the procedure recognize the column names?

a procedure is not directly associated with a table, it could be a single, multiple, or no tables involved

in the section that says do your work here, lets say we are doing a single insert

create procedure ProcedureName
(
@name varchar (50)
)
as
BEGIN
  insert into TableName (NAME) 
  values (@name)
END

thats how the 'link' happens so to speak with tables

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.