Create Table using storeprocedure

Here is an example:

Create Proc [dbo].[TestStoreProcedure]

AS

Create Table [dbo].[TestTable]

(

[JournalVoucherNo] int NOT NULL Primary key identity(1,1),

[Description] nvarchar(max),

[Date] datetime,

[Cost] money,

[Role] char(4),

[IsAdmin] bit

[CreatedBy] int

[UpdatedBy] int


)

RETURN

* using [dbo] for including new features of 2005 and we can give another name(eg..AP,AR,GL,Budget)that we can define like that schema which make more efficient for database features.

* using brackets [] to embrace the table name or field name so that even reserved words have been used, the names are still allowed.

* the field name [Id] has been defined to be primary key and it's auto increment by 1, start from 1. (Null is not allowed for this column)

* the data type for boolean is "bit" here.

* the difference between using "char" & "varchar" is that, when you define the size for char, no matter how many characters have been stored, it'll use up all the space defined. But for "varchar", it'll allocate just the size enough to store the variables. For variable string, it's good to use "varchar" as the data type.

* The maximum size for varchar is 8000 characters.