create Table #tempTable
(
ID int IDENTITY PRIMARY KEY,
bookId int,
bookName varchar(50)
)
go
declare @a int
set @a=(select count(*) as 'aa' from sysobjects where name = '#tempTable')
select @a as 'aaaaaa'
结果为了,临时表是始终为0的
在SQL中判断一个表是否存在
<%sql="if exists (select * from sysobjects where id = object_id(N'[dbo].[phone]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[phone]"
con.execute(sql)
%>
如果表phone存在则删除phone表
其中phone是表名,con是connection对像
<br/>
<hr>
对一个表导出其脚本,里面有例子
<br/>
<hr>
SELECT count(*) <br/> FROM sysobjects <br/> WHERE name = 'jqwm'
<br/>
<hr>
<br/> SELECT count(*) <br/> FROM sysobjects <br/> WHERE name = 'yourtablename' <br/> <br/>
<br/>
<hr>
select count(*) from sysobjects where name = "tablename' and type ='U' <br/> count(*)>=1表示存在
<br/>
<hr>
select count(*) from sysobjects where name = "tablename' and type ='U' <br/> count(*)>=1表示存在 <br/> 或者如IronPromises(铁诺) 的方法,本质上一回事
<br/>
<hr>
同意楼上的 <br/>
SELECT Count(*) AS Qty
FROM MSysObjects
WHERE (((MSysObjects.Name) Like 需判断的已知表名));