BaşlayınÜcretsiz Başlayın

CASTing data

It happens often to need data in a certain type or format and to find that it's stored differently. For example:

  • Integrating data from multiple sources, having different data types, into a single one
  • Abstract data should be more readable (i.e. True/False instead of 1/0) Luckily, you don't need to make any changes in the data itself. You can use functions for explicitly converting to the data type you need (using CAST() and CONVERT()).

You are now going to explicitly convert data using the CAST() function. Remember the syntax: sql CAST(expression AS data_type [(length)])

Bu egzersiz

Functions for Manipulating Data in SQL Server

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

SELECT 
	-- Transform the year part from the birthdate to a string
	first_name + ' ' + last_name + ' was born in ' + ___(YEAR(___) AS nvarchar) + '.' 
FROM voters;
Kodu Düzenle ve Çalıştır