在Sql Server 7.0中如何得到像Paradox中的Autoinc字段(50分)

  • 主题发起人 主题发起人 cheka
  • 开始时间 开始时间
C

cheka

Unregistered / Unconfirmed
GUEST, unregistred user!

设置了一个Uniqueidentify型的字段,并在触发器中用Newid函数,
但是Delphi不支持Uniqueidentify型,那么应该怎么做呢?
 
g,提前一点,谢谢。
 
是否bde要升一下级
 
不用触发器,
query1.sql.clear;
query1.sql.add('INSERT INTO table1 VALUES(NEWID(),' + '"'+edit1.Text +'" )');
query1.ExecSQL ;
可以正常运行.

 
Look(from Transact-SQL help:SQL Server 7):
@@IDENTITY (T-SQL)

Returns the last-inserted identity value.
Syntax

@@IDENTITY

Return Types

numeric

Remarks

After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY contains the last identity value generated by the statement. If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL. If multiple rows are inserted, generating multiple identity values, @@IDENTITY returns the last identity value generated. If the statement fires one or more triggers that perform inserts that generate identity values, calling @@IDENTITY immediately after the statement returns the last identity value generated by the triggers. The @@IDENTITY value does not revert to a previous setting if the INSERT or SELECT INTO statement or bulk copy fails, or if the transaction is rolled back.

Examples

This example inserts a row into a table with an identity column and uses @@IDENTITY to display the identity value used in the new row.

INSERT INTO jobs (job_desc,min_lvl,max_lvl)

VALUES ('Accountant',12,125)

SELECT @@IDENTITY AS 'Identity'
 
ADO 支持此数据类型.
 
多人接受答案了。
 
后退
顶部