Skip to main content

System Function in SQL-Server

GETDATE() Gives current date time (server’s time zone)

E.g. SELECT GETDATE()return 2011-08-25 09:54:39.963


GETUTCDATE() Gives current date time (GMT + 0 Time zone)

E.g. SELECT GETUTCDATE() return 2011-08-25 04:27:30.163


ISDATE('Value') Returns bool value whether given value is proper date or not

E.g. SELECT ISDATE('2011-08-25') return 1

SELECT ISDATE('2011-13-25') return 0


LTRIM('Value') Trims from left

E.g. SELECT LTRIM(' SQL SERVER ') return ‘SQL SERVER


RTRIM('Value') Trims from right

E.g. SELECT LTRIM(' SQL SERVER ') return ‘ SQL SERVER‘


REPLACE() replace all occurrence of string with other string

E.g. SELECT REPLACE('SQL SERVER ','S','A') return ‘AQL AERVER


ISNUMERIC('Value') Checks whether given value is numeric or not. Gives Boolean result

E.g. SELECT ISNUMERIC(3) return 1

SELECT ISNUMERIC(‘SQL’) return 0


LEN('Value') Gives total number of characters available in given string (after right trimming)

E.g. SELECT LEN('SQL SERVER') return 10


UPPER('Value') Converts all the characters into upper case

E.g. SELECT UPPER('SqL SErVeR') return ‘SQL SERVER’


LOWER('Value') Converts all the characters into lower case

E.g. SELECT LOWER('SqL SErVeR') return ‘sql server’


SUBSTRING() Gives substring from string with specific position

E.g. SELECT SUBSTRING('SQL SERVER',2,3) return ‘QL’


REVERSE('Value')Gives reverses the string

E.g. SELECT REVERSE('SQL SERVER') return ‘REVRES LQS’

CHARINDEX() Gives position of “characters” in a string starting from specific position

E.g. SELECT CHARINDEX('S','SQL SERVER',2) return 5


SCHEMA_ID('Value') Gives ID of a given schema

E.g. SELECT SCHEMA_ID('dbo') return 1


SCHEMA_NAME('Value') Gives name of a schema with given ID

E.g. SELECT SCHEMA_NAME('1') return 0


SCOPE_IDENTITY()returns the last identity value generated for any table in the current session and the current scope

E.g. SELECT SCOPE_IDENTITY()


IDENT_CURRENT('TableName') returns the last identity value generated for a specific table in any session and any scope

E.g. SELECT IDENT_CURRENT('emp')


ISNULL(ColumnName,'Value') Replaces NULL value of a given column with passed string

E.g. SELECT ISNULL(NULL,'SQL') return SQL

SELECT ISNULL(NULL,NULL)return NULL


Comments

Popular posts from this blog

Connected and disconnected architecture in ADO.Net with Example

Connected Architecture of ADO.NET The architecture of ADO.net, in which connection must be opened to access the data retrieved from database is called as connected architecture. Connected architecture was built on the classes connection, command, datareader and transaction.  Connected architecture is when you constantly make trips to the database for any CRUD (Create, Read, Update and Delete) operation you wish to do. This creates more traffic to the database but is normally much faster as you should be doing smaller transactions. Disconnected Architecture in ADO.NET The architecture of ADO.net in which data retrieved from database can be accessed even when connection to database was closed is called as disconnected architecture. Disconnected architecture of ADO.net was built on classes connection, dataadapter, commandbuilder and dataset and dataview. Disconnected architecture is a method of retrieving a recor

HTTPHandler and HTTPModule in ASP.NET

If you want to implement pre-processing logic before a request hits the IIS resources. For instance you would like to apply security mechanism, URL rewriting, filter something in the request, etc. ASP.NET has provided two types of interception HttpModule and HttpHandler .   The web server examines the file name extension of the requested file, and determines which ISAPI extension should handle the request. Then the request is passed to the appropriate ISAPI extension.  For Example When an .aspx page is requested it is passed to ASP.Net page handler. Then Application domain is created and after that different ASP.Net objects like Httpcontext, HttpRequest, HttpResponse. HTTPModule: -    It's just like a filter. The Modules are called before and after the handler executes . -    HTTP Modules are objects which also participate the pipeline but they work before and after the HTTP Handler does its job, and produce additional services within the pipeline -  

ASP.NET Page Life Cycle with example

In this article, we are going to discuss the different methods and order they are executed during the load of an .aspx web page. Methods Description Page_PreInit Before page Initialization Page_Init Page Initialization LoadViewState View State Loading LoadPostData Postback Data Processing Page_Load Page Loading RaisePostDataChangedEvent PostBack Change Notification RaisePostBackEvent PostBack Event Handling Page_PreRender Page Pre Rendering Phase SaveViewState View State Saving Page_Render Page Rendering Page_Unload Page Unloading PreInit : The entry point of the page life cycle is the pre-initialization phase called “PreInit”. You can dynamically set the values of master pages and themes in this event. You can also dynamically create controls in this event.  Init : This event fires after each control h