Showing posts with label mssql. Show all posts
Showing posts with label mssql. Show all posts

Monday, December 29, 2014

SQL - SUBSTRING (Transact-SQL)

Syntax

SUBSTRING ( expression ,start , length )

Arguments
expression
Is a character, binary, text, ntext, or image expression.
start
Is an integer or bigint expression that specifies where the returned characters start. If start is less than 1, the returned expression will begin at the first character that is specified in expression. In this case, the number of characters that are returned is the largest value of either the sum of start + length- 1 or 0. If start is greater than the number of characters in the value expression, a zero-length expression is returned.
length
Is a positive integer or bigint expression that specifies how many characters of the expression will be returned. If length is negative, an error is generated and the statement is terminated. If the sum of start and length is greater than the number of characters in expression, the whole value expression beginning at start is returned
Sample: SELECT date, substring(recpt_desc, 1, 3), branch from DATABASE where date='2014-12-03' order by branch group by date, substring(recpt_desc, 1, 3), branch;

Monday, June 17, 2013

MS SQL:Create Index (Transact-SQL)

An index can be created before there is data in the table. Relational indexes can be created on tables or views in another database by specifying a qualified database name.

Refer  notes from: http://msdn.microsoft.com/en-us/library/ms188783.aspx

Sample:
create index PARAMETER on TABLE (COLUMN)



CREATE INDEX SHP_ID_CREATE_DATE
ON C.SHOPPER (CREATE_DATE)


CREATE INDEX ORDER_CREATE_DATE
ON E.ORDERS(CREATE_DATE)


.