Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Beginner
Jan 5, 2017

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]
GO
Here is an example result set.
Student Name Student Number
Test Name 1 - #####STU1
Test Name 2 - #####STU2
Test Name 3 - #####STU3
Test Name 4 - #####STU4
Test Name 5 - #####STU5
Hannes du Preez
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date