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

相關文章
相關標籤/搜索