--因为你是全局的临时表,所以可以这样定义:exec('create table '+@tmp+' (nouse int)')--用全局临时表,用户环境下,控制得不好会引起冲突--建议用下面的方法生成临时表名@declare @tmp sysname set @tmp = '[##good'+cast(newid() as varchar(36))+']' exec('create table '+@tmp+'(nouse int)')
to zjcxc: 用你的方法已经搞定了, 下面是我的操作BEGIN TRANSACTION declare @id bigint select top 1 @id=id from tv where status=2 and object_id('tempdb..##' +cast(id as varchar(100))) is null order by id asc exec('create table ##'+@id+'(nouse int)') select * from tv where id = @id commit transaction 等待审核,到vb用变量记录下那个id来BEGIN TRANSACTION update tv set status = 4 where id = vb记录的id变量 drop table ## + vb记录的id变量 commit transaction等下给分!
然后更新被取记录的时间为当前时间.规定记录被审核的时间必须在一个时间段内,超过这个时间段的被自动释放
http://expert.csdn.net/Expert/topic/2921/2921334.xml?temp=.7541468
不好意思,我不是故意发这么多帖的, 也浪费我这么多分:)
原因是我的adsl modem 最近老遭受攻击,即打开网页时候老返回ttl=1路由不可到达错误。 但其他的提交什么却可以! 每次都要重新启动modem(配置好了nat),我发这个帖子的时候就碰到了这个问题!! 我没看到结果,就按了f5,还没看到, 又按了f5,等我反应过来的时候就这样了
其实我只开了2个帖子,在vb, sqlserver个开了一个, 实在是不好意思!!刚我自己用方法测试成功!
但是还是有个问题
就是我定义了个变量比如
@declare @tmp varchar(100)
select @tmp = '##good'
create table @tmp (nouse int)最后一行报错误, 我希望能够用变量做创建表的名字,怎么搞?
set @tmp = '[##good'+cast(newid() as varchar(36))+']'
exec('create table '+@tmp+'(nouse int)')
用你的方法已经搞定了, 下面是我的操作BEGIN TRANSACTION
declare @id bigint
select top 1 @id=id from tv where status=2 and object_id('tempdb..##' +cast(id as varchar(100))) is null order by id asc
exec('create table ##'+@id+'(nouse int)')
select * from tv where id = @id
commit transaction 等待审核,到vb用变量记录下那个id来BEGIN TRANSACTION
update tv set status = 4 where id = vb记录的id变量
drop table ## + vb记录的id变量
commit transaction等下给分!