Select using value from parameter : Parameter « Procedure Function « SQL Server / T-SQL Tutorial

Home
SQL Server / T-SQL Tutorial
1.Query
2.Insert Delete Update
3.Table
4.Table Join
5.Data Types
6.Set Operations
7.Constraints
8.Subquery
9.Aggregate Functions
10.Date Functions
11.Math Functions
12.String Functions
13.Data Convert Functions
14.Analytical Functions
15.Sequence Indentity
16.View
17.Index
18.Cursor
19.Database
20.Transact SQL
21.Procedure Function
22.Trigger
23.Transaction
24.XML
25.System Functions
26.System Settings
27.System Tables Views
28.User Role
29.CLR
SQL Server / T-SQL Tutorial » Procedure Function » Parameter 
21.13.8.Select using value from parameter
4>
5CREATE TABLE Authors(
6>   au_id    varchar(11NOT NULL,
7>   au_lname varchar(40NOT NULL,
8>   au_fname varchar(20NOT NULL,
9>   phone    char(12)    NOT NULL,
10>   address  varchar(40NULL,
11>   city     varchar(20NULL,
12>   state    char(2)     NULL,
13>   zip      char(5)     NULL,
14>   contract bit         NOT NULL
15);
16> GO
1>
2CREATE PROC AuthorsInState
3>   @state char(2)
4> AS
5SELECT
6>   *
7FROM
8>   authors
9WHERE
10>   state = @state
11> GO
1>
2> drop proc AuthorsInState;
3> GO
1>
2> drop table Authors;
3> GO
1>
2>
3>
4>
21.13.Parameter
21.13.1.The syntax for declaring parameters
21.13.2.Parameterization: @parameter_name [AS] datatype [= default|NULL] [VARYING] [OUTPUT|OUT]
21.13.3.Procedure with default parameter value
21.13.4.Check parameter value with if statement
21.13.5.Procedure with two parameters
21.13.6.Passing the ORDER BY Column as a Parameter, Using a Column Number
21.13.7.Passing the ORDER BY Column as a Parameter, Using Dynamic Execution
21.13.8.Select using value from parameter
21.13.9.Call procedure with parameter name
21.13.10.Parameter with null default value
21.13.11.Pass column as the parameter
21.13.12.parameters can be passed explicitly by value
21.13.13.stored procedure can be executed with the parameter and assigned value
21.13.14.Wildcards in Parameters
21.13.15.Check value range for input parameter
21.13.16.Code that omits both optional parameters
21.13.17.Code that omits one optional parameter
21.13.18.Code that passes the parameters by position
21.13.19.Code that passes the parameters by name
21.13.20.Stored Procedure with Cursor Parameter
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.