Using REPLICATE for SQL Strings

The following example replicates a # character five times in front of a Student Number in the Students table:

SELECT [Student Name], REPLICATE('#', 5) + [Student Number] AS 'Student Number'FROM [Students]GOHere is an example result set.Student Name Student NumberTest Name 1 - #####STU1Test Name 2 - #####STU2Test Name 3 - #####STU3Test Name 4 - #####STU4Test Name 5 - #####STU5
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Related Posts