Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12554

SQL Server Engine Interprets Carriage Feed different from Line Feed

$
0
0

From the PRINT Output of the below statement if you parse the statements

declare @sql VARCHAR(MAX)

SELECT @SQL = COALESCE(@sql + CHAR(13) + 'use [master] ','use [master] ' + CHAR(13)) + 'ALTER DATABASE ' + quotename(name) + ' COLLATE SQL_Latin1_General_CP1_CS_AS ' + CHAR(13) + 'GO' from sys.databases where name not in ('master','tempdb','model','msdb','ReportServer','ReportServerTempDB','distribution') ORDER BY name PRINT @SQL

It would throw error, but I replace CHAR(13) with CHAR(10) OR CHAR(10) + CHAR(13) (thanks to one of colleague) the same statements just works fine.

How is line feed different from carriage line feed and what is the standard one should follow for such dynamic SQL Generation.

Thanks,

Varun


Viewing all articles
Browse latest Browse all 12554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>