Complied by John .
K & Bharat
DATA TYPES
Char – Fixed data type. So it takes up whatever size is assigned, even if not used.
Varchar – Variable data type. Takes up space of the #character entered and not
the size assigned.
Bit type – datatype which express Boolean value. Used to store Boolean
information. Before 7.0 it stores only two states (0 and 1) from 7.0 on it has 3 states
(0, 1 , NULL)
Int – (4), BigInt – (8) From SQL2000 only, Small Int – (2), TinyInt – (1)
User defined data-types
Lets you extend the base SQL server data types by providing a descriptive name
and format to the database. Eg. Flight_# appears in many tables and all these
tables have varchar(8) Create a user defined data-type.
1. If a stored procedure is taking a table data type, how it looks?
• A table variable behaves like a local variable. It has a well-defined scope, which is the
function, stored procedure, or batch in which it is declared.
Within its scope, a table variable may be used like a regular table. It may be applied
anywhere a table or table expression is used in SELECT, INSERT, UPDATE, and
DELETE statements. However, table may not be used in the following statements:
INSERT INTO table_variable EXEC stored_procedure
SELECT select_list INTO table_variable statements.
table variables are cleaned up automatically at the end of the function, stored procedure,
or batch in which they are defined.
• table variables used in stored procedures result in fewer recompilations of the stored
procedures than when temporary tables are used.
• Transactions involving table variables last only for the duration of an update on the table
variable. Thus, table variables require less locking and logging resources.
Jan 2007