T-SQL TO U-SQL DATA TYPE CONVERSION

When working with code generated solutions we often need to convert datasets from SQL Server (T-SQL) data types to Azure Data Lake Analytics (U-SQL) data types. As you probably know U-SQL has a hybrid syntax of T-SQL and C# which uses .Net data types. That said the Microsoft doc’s data type conversion table doesn’t always help us, link below.

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings

For example, a T-SQL int doesn’t convert to an Int32 in U-SQL, even though this is correct for .Net. We need to be a little more general when going from T-SQL to U-SQL and also use the correct casing.

Here is the Adatis the data type conversion table from T-SQL to U-SQL:

T-SQL Data TypeU-SQL Data Type
bigintlong
binarybyte[]
bitbool
charstring
dateDateTime
datetimeDateTime
datetime2DateTime
datetimeoffsetDateTime
decimaldecimal
FILESTREAM attributebyte[]
floatdouble
imagebyte[]
intint
moneydecimal
ncharstring
ntextstring
numericdecimal
nvarcharstring
realfloat
rowversionbyte[]
smalldatetimeDateTime
smallintshort
smallmoneydecimal
sql_variantbyte[]
textstring
timeDateTime
timestampbyte[]
tinyintbyte
uniqueidentifierGuid
varbinarybyte[]
varcharstring
xmlstring

Finally, and again, mainly for my own reference here is a T-SQL script to create this as a database table.

Data Type Mappings.sql.zip