How to handle blank space in table

Shambhu Rai 1,381 Reputation points

Hi Expert, How to enter blank space and default date in timestamp column create table tabletest1 (col1 char(23), col2 int,col3 decimal(3,3),col4 timestamp) expected values User's image

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,233 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,515 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 98,751 Reputation points

    In SQL server, the timestamp data type has nothing to do with date and time. It's a very unfortunate name for a binary(8) column with the special property that it is automatically updated with a database-wide monotonically increasing value. An alternative name for this data type is rowversion. You cannot enter any data yourself in such a column.

    In other products, timestamp is indeed a data type for date and time; in fact that is even the ANSI standard. Typically, you can't enter a space into such a column, since space does not belong to the domain of dates. Exactly what happens, depends on the product. In SQL Server, if you enter a space into a date/time column, you will in fact get the value 1900-01-01 00:00:00.000.

    If you don't want to enter a date, for instance, because the date is not known, you would typically leave it NULL.

    1 person found this answer helpful.

  2. ZoeHui-MSFT 30,411 Reputation points

    Hi @Shambhu Rai, Try with below.

    UPDATE ...
    SET value = '   ' + value

    Regards´╝î Zoe Hui

    If the answer is helpful, please click "Accept Answer" and upvote it.