Previous Topic

Next Topic

Inhoudsopgave

Book Index

Print

In ASE, the print statement supports formatted strings. In MS SQL Server, formatted strings are not supported. MS SQL Server allows string expressions, whereas ASE only supports constants and variables.

print {‘format_string’ | @local_variable} [, argument [,...n]]

print {‘message_string’ | @local_variable | string_expression}

Example

declare @v varchar(30)

set @v = 'My flexible message'

print 'My static message'

print @v

go

-- Only works on ASE

declare @f varchar(30)

set @f = 'My %1! %2! message nr. %3!'

print 'My %1! %2! message', 'static', 'formatted' nr. %3!, 1

print @f, 'flexible', 'formatted', 2

go

-- Only works on MS SQL Server

print RTrim(Cast(GetDate() as nvarchar(30)))