English 中文(简体)
我如何在2005年服务器中使用双边投资条约
原标题:How I should use BIT in SQL Server 2005

关于质量评估。

我在核对基数中某些具体条件方面有着细微的功用,它为真实或假冒收回了双边投资条约的价值。

我现在不知道我应如何填写@BIT参数。

如果是我写的话。

set @bit = convert(bit,1)

set @bit = 1

set @bit= true 

function will w或k anyway but I do not know which method is recommended f或 daily use.

Another question, I have table in my base with around 4 million rec或ds, daily insert is about 4K rec或ds in that table.

我现在想在此表上加上我刚才提到的宝贵功能。

类似情况

ALTER TABLE fin_stavke
ADD CONSTRAINT fin_stavke_knjizenje CHECK ( dbo.fn_ado_chk_fin(id)=convert(bit,1))

“id”是表fin_stavke和dbo.fn_ado_chk_fin的主要关键所在。 like

create FUNCTION fn_ado_chk_fin
(
    @stavka_id int
)
RETURNS bit
AS
BEGIN
declare @bit bit

if exists (select * from fin_stavke where id=@stavka_id and doc_id is null and protocol_id is null)
        begin
            set @bit=0


        end
    else
        begin
            set @bit=1
        end
return @bit;
END
GO

Will this type and method of checking constraint will affect badly perf或mance on my table and SQL at all ?

如果还有更好的办法来增加对这一表的控制,请让我知道。

最佳回答

我可能错了,但从表面上看,你似乎只想检查,不是<条码>doc_id<>/code>和protocol_id?

您可以添加一个<>明显的制约因素>以实现这一目标。

ALTER TABLE fin_stavke
ADD CONSTRAINT fin_stavke_knjizenje CHECK ( doc_id IS NOT NULL OR protocol_id IS NOT NULL)
问题回答

I 用途

 set @bit = 1

它是安全的(将事实归咎于某一方感到错失),而皈依正义似乎毫无意义。

我总是把借方视为1或0。 我坚持这一点。 每个人都会知道你做了些什么。

这一限制将影响你所插入的表现,但不会影响很多,因为你正在寻求桌上的主要关键。 这很可能是你能够做的最廉价的检查。

2. 借方变量可分为:

set @bit = 1

有时,为了避免暗中转换,你需要实际的比值,那么你可以做合法转换:

set @bit = cast(1 as bit)

在将其分配到一个变量时,没有实际的区别,但是,在质询被平分而不是当它被执行时,转换会发生。 我曾几次使用过这一方法,并实际表现差异。





相关问题
How to write this T-SQL WHERE condition?

I ve got two tables: TableA Col1 Col2 TableB Col3 Col4 I want to join them together: SELECT * from TableA join TableB ON (...) Now, in place of ... I need to write an expression ...

Customer and Order Sql Statement

TSQL query to select all records from Customer that has an Order and also select all records from customer that does not have an Order. The table Customer contains a primary key of CustomerID. The ...

Recommended way of querying multiple Versioned tables

Have a win 2003 box with MSSQL 2005 running on it. There is a database which is populated every morning with new/modified SalesOrder made the previous day. The database has several tables: SalesOrder, ...

update duplicate record

I have a table with the following fields Id Name IsPublic i need to write a sql query that updates IsPublic to false where name has a duplicate. Only one of the duplicates should have IsPublic = ...

Define variable to use with IN operator (T-SQL)

I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"? ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签