samuraivader
samuraivader

Reputation: 43

Printing spaces in SQL Server

I was playing with SQL Server at Hackerrank and I tried to print some spaces and something else after it.

I tried using the code:

PRINT space(5) + replicate('a',3)

but I didn't get the five spaces, just the three a's.

I also tried using REPLICATE(' ',5), but it also didn't work.

Can anybody please tell me if there is a problem with my SQL code or if it's just a hackerrank problem?

Upvotes: 0

Views: 753

Answers (1)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 88971

No repro:

PRINT space(5) + replicate('a',3)

outputs the spaces before the a's:

     aaa

Completion time: 2020-03-28T18:06:55.8805131-05:00

Upvotes: 1

Related Questions