SQL 判断表的存在,查表结构

--判断存在性 ide

if exists (select * from sysobjects where id = object_id(N'[dbo].[T_Table]') and objectproperty(id,N'IsUserTable') = 1)
begin
 drop table T_OriginalStocks
end
create table T_Table(ID bigint identity(1,1) not null primary key,UserID bigint,StockNumber bigint,TradableStock bigint)on [primary] it

--查表结构 table

select [name] from syscolumns where id = object_id(N'[dbo].[T_Table]') and objectproperty(id,N'IsUserTable') = 1 object

--建立临时表 select

if object_id('tempdb..#tempTable') is not null
begin
    drop table #tempTable
end

create table #tempTable(dsf int)

select * from  #tempTable im

相关文章
相关标签/搜索