Call the stored procedure : Procedure Call « Store Procedure Function « SQL Server / T-SQL

SQL Server / T-SQL
1. Aggregate Functions
2. Analytical Functions
3. Constraints
4. Cursor
5. Data Set
6. Data Type
7. Database
8. Date Timezone
9. Index
10. Insert Delete Update
11. Math Functions
12. Select Query
13. Sequence
14. Store Procedure Function
15. String Functions
16. Subquery
17. System
18. Table
19. Table Joins
20. Transact SQL
21. Transaction
22. Trigger
23. View
24. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL » Store Procedure Function » Procedure Call 
Call the stored procedure

 


11create table Billings (
12>     BankerID           INTEGER,
13>     BillingNumber      INTEGER,
14>     BillingDate        datetime,
15>     BillingTotal       INTEGER,
16>     TermsID            INTEGER,
17>     BillingDueDate     datetime ,
18>     PaymentTotal       INTEGER,
19>     CreditTotal        INTEGER
20>
21);
22> GO
1>
2INSERT INTO Billings VALUES (11'2005-01-22', 1651,'2005-04-22',123,321);
3> GO

(rows affected)
1INSERT INTO Billings VALUES (22'2001-02-21', 1651,'2002-02-22',123,321.);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (33'2003-05-02', 1651,'2005-04-12',123,321);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (44'1999-03-12', 1651,'2005-04-18',123,321);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (55'2000-04-23', 1651,'2005-04-17',123,321);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (66'2001-06-14', 1651,'2005-04-18',123,321);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (77'2002-07-15', 1651,'2005-04-19',123,321);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (88'2003-08-16', 1651,'2005-04-20',123,321);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (99'2004-09-17', 1651,'2005-04-21',123,321);
2> GO

(rows affected)
1INSERT INTO Billings VALUES (00'2005-10-18', 1651,'2005-04-22',123,321);
2> GO

(rows affected)
1>
2>
3CREATE PROC spInsertBilling
4>        @BankerID    int,           @BillingNumber  varchar(50),
5>        @BillingDate smalldatetime, @BillingTotal   money,
6>        @TermsID     int,           @BillingDueDate smalldatetime
7> AS
8> DECLARE @ErrorVar int
9INSERT Billings (BankerID)
10> VALUES (@BankerID)
11> SET @ErrorVar = @@ERROR
12> IF @ErrorVar <> 0
13>     BEGIN
14>         IF @ErrorVar = 547
15>             PRINT 'Not a valid BankerID!'
16>         ELSE
17>             PRINT 'An unknown error occurred.'
18>         RETURN @ErrorVar
19>     END
20> GO
1>
2> DECLARE @ReturnVar int
3> EXEC @ReturnVar = spInsertBilling
4>      799,'ZXK-799','2002-07-01',299.95,1,'2001-08-01'
5> PRINT 'Return code was: ' + CONVERT(varchar,@ReturnVar)
6> GO

(rows affected)

(rows affected)
Return code was: 0
1>
2>
3> drop PROC spInsertBilling;
4> GO
1>
2>
3> drop table Billings;
4> GO
1>

 
Related examples in the same category
1. Use procedure as a parameteried view
2. the parameters can be passed explicitly by value
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.