ExpertConnect - Mentoring & Discussions

You can join mentoring & discussions for Free Ask Question, Give Answer, Discuss IT Problems, Learn, and Grow

2017-10-20 14:12:50 4

Transact SQL

Topic menu

2018-05-04 12:47:20 1
Profile picture of Shanika  Rathnayake
Posted: May 4, 2018

So, then a follow up. What’s the difference between char() and varchar()?

Comment (1) ·  Like (2)
Profile picture of Jeff Rathjen

Jeff Rathjen May 4, 2018

Sure no probs.
char() is a fixed length stirng. If you declare a variable : Declare @MyChar char(5); you may set it equal to any ASCII string that contains 5 or fewer characters. However, if you store fewer than 5, it will still occupy 5 bytes. Varchar is a variable length Data Type. If you : Declare @MyVarChar varchar(5); and then insert 2 characters into it, it will occupy only 2 bytes. BTW, same difference between nchar() and nvarchar().

Like (1)

Write a new comment...
Ready to post? select an option: