convert sql code example

Example 1: sql server convert string to date

Cast( '2011-07-07' as date ) as convertedDate

Example 2: select CONVERT(NUMber(10,2),dailybroadbandusagedsmbyte)

select CONVERT(NUMber(10,2),dailybroadbandusagedsmbyte)

Example 3: sql cast

-- Specifically for Oracle

-- EXAMPLE
CAST('732.98' AS INT)

/* SYNTAX
CAST(<value_to_cast> AS <data_type_to_cast_to>)
*/

Example 4: sql convert

-- CAST Syntax:  
CAST ( expression AS data_type [ ( length ) ] )  
  
-- CONVERT Syntax:  
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Example 5: into sql

#The SELECT INTO statement selects data from one table and inserts it into a different table. 
#The SELECT INTO statement is most often used to create backup copies of tables. 
syntax->SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_tablename 
///example///
SELECT *
INTO Persons_Backup
FROM Persons

Tags:

Sql Example