Posts

How to compare identity values returned by IDENT_CURRENT, @@IDENTITY and SCOPE_IDENTITY?

Image
Comparing identity values returned by IDENT_CURRENT, @@IDENTITY and SCOPE_IDENTITY The following example shows the different identity values that are returned by IDENT_CURRENT, @@IDENTITY, and SCOPE_IDENTITY.

How to return the last identity value generated for a specified table?

Returning the last identity value generated for a specified table: Following example returns the last identity value generated for the Person.Address table in the AdventureWorks2012 database. USE AdventureWorks2012; GO SELECT IDENT_CURRENT ('Person.Address') AS Current_Identity; GO OR Following example returns the last identity value generated for the College: USE College; GO SELECT IDENT_CURRENT ('Student') AS Current_Identity; GO

DATALENGTH Function

DATALENGTH (Transact-SQL) This function returns the number of bytes used to represent any expression. Syntax  DATALENGTH ( expression )  Arguments expression Is an expression of any data type. Return Types bigint if expression is of the varchar(max), nvarchar(max) or varbinary(max) data types; otherwise int . Remarks DATALENGTH is especially useful with varchar, varbinary, text, image, nvarchar, and ntext data types because these data types can store variable-length data. The DATALENGTH of NULL is NULL. Note Compatibility levels can affect return values. For more information about compatibility levels, see ALTER DATABASE Compatibility Level (Transact-SQL). Examples The following example finds the length of the Name column in the Product table. USE AdventureWorks2012; GO SELECT length = DATALENGTH(Name), Name FROM Production.Product ORDER BY Name; GO OR This following example find the length of ID column in Student table: SELECT length ...

Data Type Functions

Data Type Functions (Transact-SQL) Data type functions return information about various data type values. In This Section we read the following scalar functions: DATALENGTH (Transact-SQL) IDENT_SEED (Transact-SQL) IDENT_CURRENT (Transact-SQL) IDENTITY (Function) (Transact-SQL) IDENT_INCR (Transact-SQL) SQL_VARIANT_PROPERTY (Transact-SQL)

Instructions to write C Program

C Instructions Now that we have written a few programs let us look at the instructions that we used in these  programs. There are basically three types of instructions in C: Type Declaration Instruction Arithmetic Instruction Control Instruction The purpose of each of these instructions is given below:      Type declaration instruction To declare the type of variables used in a C program.             Arithmetic instruction To perform arithmetic operations between constants and variables.             Control instruction To control the sequence of execution of various statements in a C program. Since, the elementary C programs would usually contain only the type declaration and the arithmetic instructions; we would discuss only these two instructions at this stage. The other types of instructions would be discussed in det...

Receiving Input of C Program

Receiving Input In the program discussed below we assumed the values of p , n and r to be 1000, 3 and 8.5. Every time we run the program we would get the same value for simple interest. If we want to calculate simple interest for some other set of values then we are required to make the relevant change in the program, and again compile and execute it. Thus the program is not general enough to calculate simple interest for any set of values without being required to make a change in the program. Moreover, if you distribute the EXE file of this program to somebody he would not even be able  to make changes in the program. Hence it is a good practice to create a program that is general enough to work for any set of values. To make the program general the program itself should ask the user to supply the values of p , n and r through the keyboard during execution. This can be achieved using a function called scanf( ) . This function is a counter-part of the printf( ) function....

Compilation and Execution of C Program

Compilation and Execution Once you have written the program you need to type it and instruct the machine to execute it. To type your C program you need ano ther program called Editor. Once the program has been typed it needs to be converted to machine language (0s and 1s) before the machine can execute it. To carry out this conversion we need another program called Compiler. Compiler vendors provide an Integrated Development Environment (IDE) which consists of an Editor as well as the Compiler. There are several such IDEs available in the market targeted towards different operating systems. For example, Turbo C, Turbo C++ and Microsoft C are some of the popular compilers that work under MS-DOS; Visual C++ and Borland C++ are the compilers that work under Windows, whereas gcc compiler works under Linux. Note that Turbo C++, Microsoft C++ and Borland C++ software also contain a C compiler bundled with them. If you are a beginner you would be better off using a simple compiler like...