1. NULL will never be NULL. How do I set NULLNULL? Declare @ tabtable (idint) insertinto @ tabselect1select * from @ tabwherenullnull: Use setANSI_NULLSoff before comparison. Do not forget to set it to the original default value after comparison. :) setANSI_NULLSon2. Distributed
1. NULL never = NULL. How do I set NULL to NULL? Declare @ tab table (id int) insert into @ tab select 1 select * from @ tab where null = null solution: set ANSI_NULLS off before comparison, do not forget to set it to the original default value after comparison. :) set ANSI_NULLS on 2. distributed tasks
1. NULL never = NULL. How do I set NULL to NULL?
Declare @ tab table (id int)
Insert into @ tab select 1
Select * from @ tab where null = null
Solution: Use set ANSI_NULLS off before comparison. Do not forget to set it to the original default value after comparison. :) set ANSI_NULLS on
2. distributed transactions always encounter errors.
Symptom:
Begin tran
Select * from [192.168.1.100]. aigdollar. dbo. shoporderinfo
Commit
This operation cannot be performed because the ole db Provider 'sqlodb' cannot start distributed transactions.
[OLE/DB provider returned message: a new transaction cannot be registered with a specified transaction processor. ]
Solution:
Open the Security Configuration of MSDTC and select:
Network DTC Access.
Allow inbound traffic.
Allow outbound traffic.
Verification is not required.
Enable the transaction Ineternet transaction (TIP transaction ).
Enables XA transactions.
DTC Logon account: NT Authority \ NetworkService
The firewall opens port 135 (RPC) and allows MSDTC (or port 1885 ).
OK!
Microsoft info: http://support.microsoft.com/kb/Q899191
3. How to Find the primary key rather than the index in the SQL Server system table?
The following code can only find the index:
Create table [abc] (
[Id] [int] not null,
[Con] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL,
CONSTRAINT [PK_abc] PRIMARY KEY NONCLUSTERED
(
[Id]
) ON [PRIMARY]
) ON [PRIMARY]
GO
Create unique clustered index [ic] ON [dbo]. [abc] ([con]) ON [PRIMARY]
GO
Select object_name (id ),*
From dbo. sysindexkeys
Where object_name (id) = 'abc'
Solution:
Http://www.itdb.cn/n/200605/22/n20060522_6914.shtml
The analysis is dizzy.
Select * from sysobjects where parent_obj = object_id ('abc ')
Select * from sysindexes where id = object_id ('abc ')
Select * from sysindexkeys where id = object_id ('abc ')
So the following makes sense.
SELECT *
FROM syscolumns as Col join sysobjects as Obj on (Col. id = Obj. parent_obj)
WHERE (Obj. xtype = 'pk ')
And Obj. parent_obj = object_id ('abc ')
And Obj. name IN
(
SELECT name
FROM sysindexes as ix
WHERE ix. id = object_id ('abc') AND ix. indid IN
(
SELECT indid
FROM sysindexkeys as ik
WHERE (id = object_id ('abc') AND ik. colid IN
(
SELECT colid
FROM syscolumns as col2
WHERE col2.id = object_id ('abc') AND col2.name = Col. name
)
)
)