如果用户没有提供任何sqlserver表列的值,那么它的默认值是什么? [英] If any sqlserver table column is not provided a value by the user ,whats the default value in it ?

查看:336
本文介绍了如果用户没有提供任何sqlserver表列的值,那么它的默认值是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户没有提供任何sqlserver表列的值,那么它的默认值是什么?



如果是空格值,那么如何我可以将它设置为Null吗?

我可以在那里设置任何默认值吗?



i正在针对列中的表触发sql查询可以接受一个空值,但由于用户没有提供任何值 - 它承认一个空格但一个NULL ..但我希望它是null,什么是问题??

If any sqlserver table column is not provided a value by the user ,whats the default value in it ??

if it is a space value ,then how can i set it to Null ??
can i set any default value there ?

i was firing a sql query against a table where column can accept a null value ,but as a user did not provided any value for that --- it conceded a space "" but NOT a NULL ..but i expect it to be null ,whats d problem ??

推荐答案

1。如果你选中了Allow Nulls,当你插入没有任何值时它将为null。

2.代码后面的值将为空如果它是db中的Varchar数据类型

3.您可以设置默认值(转到表格的设计视图 - >点击列名称 - >查看列属性并找到默认值或绑定 - >在这里您可以设置默认值value。)或
1. If you checked Allow Nulls, It will be null when you insert without any value.
2. The value will be empty in code behind If it is Varchar data type in db
3. You can set default value (Go to design view of the table--> click on the column name --> Look into the column property and find Default value or binding--> here you can set your default value.) or
ALTER TABLE [dbo].[tbloptions] ADD  DEFAULT ('default value') FOR [Options]


如果用户没有提供任何sqlserver表列的值,那么它的默认值是什么?

它不依赖于用户。它完全掌握在拥有它的开发者/你手中。在数据库中创建表时,可以定义字段的默认值。



现在,如果用户没有发送任何内容,您可以有多个地方/方式来处理它:

1.发送所需的值插入/更新时前端到数据库

2.如果没有传递任何内容,则为数据库中的列设置默认值或将其保留为NULL



所以,是默认值可以在那里,由你而不是你的用户驱动。
If any sqlserver table column is not provided a value by the user ,whats the default value in it ??
It''s not user dependent. It is totally in hands of developer/you who owns it. While creating tables in the database, you can define the default value of the fields.

Now, if nothing is send by user, you can have multiple places/ways to handle it:
1. Send desired value from frontend to DB while insertion/updation
2. Have defaults for the column in the database if nothing is passed or leave it as NULL

so, yes defaults can be there and is driven by you and not your user.


不确定用户如何不知道一个TABLE,但你可以开始了解更多通过查询系统来解决所有问题:

Not sure exactly how a user doesn''t know about a TABLE, but you could start to know more about everything by querying the system:
USE [sr_database]
GO
SELECT [object_id], [name], [column_id] FROM sys.columns WHERE [object_id] > 99 ORDER BY [name]



返回很可能是用户创建的表。然后使用[object_id]和交叉引用的东西,它们将返回用户创建的其他内容,可能仍在其内存中的名称等。如果默认值出现,他会对himelf说。 ..啊哈!


The return is most likely to be tables that the user created. Then use the [object_id] and cross reference things that''ll return other stuff that the user created, names that might still be in his memory, etc. If the "default" value comes up, he''ll say to himelf ... "aha!"


这篇关于如果用户没有提供任何sqlserver表列的值,那么它的默认值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆