How to handle blank space in table

Shambhu Rai 1,411 Reputation points
2024-02-11T04:14:48.8966667+00:00

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.
13,361 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,601 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 107.1K Reputation points
    2024-02-11T13:10:20.03+00:00

    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 35,556 Reputation points
    2024-02-12T03:20:15.7833333+00:00

    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.