REPLICATE string : REPLICATE « String Functions « SQL Server / T-SQL

SQL Server / T-SQL
1. Aggregate Functions
2. Analytical Functions
3. Constraints
4. Cursor
5. Data Set
6. Data Type
7. Database
8. Date Timezone
9. Index
10. Insert Delete Update
11. Math Functions
12. Select Query
13. Sequence
14. Store Procedure Function
15. String Functions
16. Subquery
17. System
18. Table
19. Table Joins
20. Transact SQL
21. Transaction
22. Trigger
23. View
24. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL » String Functions » REPLICATE 
REPLICATE string


25>
26> IF EXISTS(SELECT name FROM sys.tables
27>     WHERE name = 'T')
28>     DROP TABLE T
29> GO
1>
2CREATE TABLE T (
3>     c1 int,
4>     c2 varchar(8000)
5)
6> GO
1>
2> DECLARE @v1 varchar(max)
3>
4> SET @v1 = REPLICATE('A',7999'B'
5INSERT T VALUES (1, @v1)
6SELECT RIGHT(c2,2'Right of c2' FROM T
7>
8> SET @v1 = @v1 + 'B'
9INSERT T VALUES (2, @v1)
10SELECT RIGHT(c2,2'Right of c2' FROM T
11> GO

(rows affected)
Right of c2
-------------
AB
Msg 8152, Level 16, State 10, Server JAVA2S\SQLEXPRESS, Line 9
String or binary data would be truncated.
The statement has been terminated.

(rows affected)
Right of c2
-------------
AB

(rows affected)
1>
2> drop table t
3> GO
           
       
Related examples in the same category
1. REPLICATE: replicate the same string several times
2. REPLICATE('*', 20 - LEN(Name))
3. Use set to assign value to a variable with replicate function
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.