posh | Powershell‎ > ‎posh | .NET‎ > ‎

posh.net | SQL type function in PowerShell

SELECT 'FUNCTION ' + NAME + ' {' + CHAR(10) +
' PARAM(' + CHAR(10) +
' $VALUE' + CHAR(10) +
' )' + CHAR(10) +
' RETURN [System.Data.DbType]::, $VALUE' + CHAR(10) +
'}'
, '"' + name + '"'
, * FROM SYS.types order by name

declare @var nvarchar(max) = 'create table tttc ('
select @var += '[' + name + '] ' + name + ', ' + char(10) from SYS.types
select @var + ')'
Comments