Question:
SQL Server 2005 Stored Procedures Help!?
2010-08-17 10:59:26 UTC
Using the "Northwind" example database on SQL Server 2005 I need to do the following stored procedures, wich I have no idea how to do :'(
-----------------------------------------------------------------

INSERT (any table from that database)
DELETE from (table) where ID=(whatever you want from the table)
UPDATE from (table) where ID=(whatever you want)
SELECT from (table) where ID=(whatever you want)

Repeat this process with any other table from Northwind with any ID.

I do not know how to put this into stored procedures I know they use @'s or %'s in their format or something! Help would be great!

Have a nice day guys, and sorry for my ignorance!
Three answers:
TheMadProfessor
2010-08-17 11:11:06 UTC
Take a look here for a fairly elementary tutorial concerning stored procedures: http://www.sql-server-performance.com/articles/dba/stored_procedures_basics_p1.aspx
lambda_chi_putts
2010-08-17 18:34:19 UTC
CREATE PROCEDURE dbo.myTestDelete(@id int)

AS

SET NOCOUNT ON



DELETE FROM [Tablename] WHERE ID = @id

GO



Select is very similar.



Inserts and updates are much more complicated as it depends on the table in question. You basically need to send in a value for every column in the table. But the concept is the same ... send in all the values you need to build the query and where you would do something like "WHERE ID = 5" in a normal query, you will replace that "5" with a variable (E.G. @id).
?
2010-08-17 19:41:57 UTC
I would reverse order 1st test the table,



SELECT FROM Table (CUSTOMER) where ID=1



Your UPDATE will require knowledge of what field / table and data you want to update,

which can be gleen from the SELECT query



Your delete it if just a class assignment can be a single record,



your insert syntax is generally

NSERT INTO phone_book VALUES ('John Doe', '555-1212');


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...