Programming in MS SQL Server 2012

NULL Parameter Data



The following example describes CREATE PROCEDURE with NULL parameter value. It is optional to pass parameter data value while execute this stored procedure. By default, this stored procedure returns ALL Tables Information of EBusiness Database. Based on input parameter data value, this stored procedure returns particular Table Information.

The following Transact-SQL statements are used to retrieve all or particular table(s) information based on NULL or given input parameter data value.

-- Example 108 --

 

USE EBusiness

GO

 

IF EXISTS (SELECT *

           FROM sysobjects

           WHERE name = N'dbo.usp_TableInformation' AND type = 'P')

           DROP PROCEDURE dbo.usp_TableInformation

GO

 

CREATE PROCEDURE dbo.usp_TableInformation

@TableName varchar(255) = NULL

AS

IF @TableName IS NULL

   SELECT * FROM INFORMATION_SCHEMA.TABLES

ELSE

   SELECT * FROM INFORMATION_SCHEMA.COLUMNS

   WHERE TABLE_NAME = @TableName


Query Output Screen




Query Output Screen



* * * * *


Email Your Comment To AUTHOR