Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why MS Visual Studio passes empty spaces to SQL Server columns?

I am developing a Library Management System using Visual Studio 2015 as a front end and Microsoft SQL Server 2014 as back-end to store data.

This is my table design:

enter image description here

But when I try to pass data from Visual Studio, it saves as blank spaces to the defined length.

enter image description here

For example if store a text contain 10 characters on title remaining 490 store as blank space.

The highlighted are the blank space in the column. If I set the length 10 which is default I cannot store data more than 10

Is there any solution for this? is this a issue on my database or Visual Studio?

like image 882
NaFi Avatar asked Mar 02 '26 10:03

NaFi


1 Answers

You're using the wrong data type. nchar is fixed length. You need to use nvarchar (variable length).

like image 146
benjrb Avatar answered Mar 05 '26 02:03

benjrb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!