SQL Server String Concatenation with Null

后端 未结 10 819
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 13:51

I am creating a computed column across fields of which some are potentially null.

The problem is that if any of those fields is null, the entire computed column will

10条回答
  •  广开言路
    2020-11-27 14:35

    In Sql Server:

    insert into Table_Name(PersonName,PersonEmail) values(NULL,'xyz@xyz.com')
    
    PersonName is varchar(50), NULL is not a string, because we are not passing with in single codes, so it treat as NULL.
    

    Code Behind:

    string name = (txtName.Text=="")? NULL : "'"+ txtName.Text +"'";
    string email = txtEmail.Text;
    
    insert into Table_Name(PersonName,PersonEmail) values(name,'"+email+"')
    

提交回复
热议问题