惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
WordPress大学
WordPress大学
小众软件
小众软件
IT之家
IT之家
腾讯CDC
月光博客
月光博客
量子位
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - AaronLi

E10——打印行序 E10——BOM展下阶CTE写法 E10——计算品号的使用情况(最近五年):连续X年在用 SQL&ERP——通过品号递归BOM往上找到最top的主件 E10——在线建档,单头取单身行的数据 SQLSERVER——XML转数据表输出(E10的PickList转成数据表) SQLServer数据库日志太大收缩操作指南 泛微OA——修改数据库密码 泛微OA——建模-查询,链接字段跳转到流程的路径写法 SQLSERVER——PIVOT列转行 SQL——练习:上展BOM SQL——练习:往下展开BOM SQL——CHARINDEX,找到字符(char)的位置(index) Sqlserver 根据年月获取第一天和最后一天 EXCEL生成GUID 多种格式 E10——智能菜单 E10——凭证报表序号按流水自然排序 E10——函数GetTimeDiff(DateTime dt1,DateTime dt2,int type) E10——GetEntityProperty方法 E10——脚本中GUID的值如何判断是否相等?
[转] 判断表(临时表),存储过程是否存在
AaronLi · 2023-02-02 · via 博客园 - AaronLi

1.判断 正式表或者存储过程是否存在
select * from dbo.sysobjects where id=OBJECT_ID(N'dbo.Users') and type='U' --U表示表

select * from dbo.sysobjects where id= object_id(N'usp_InsertAliPayFeedback') and type='P' --P表示存储过程

2.判断 临时表类型
select * from tempdb.dbo.sysobjects where id= OBJECT_ID(N'tempdb.dbo.#tempa') and type='U' --U表示表

select * from tempdb.dbo.sysobjects where id= OBJECT_ID(N'usp_InsertAliPayFeedback') and type='P' --P表示存储过程

对象类型。可以是下列值之一:
C = CHECK 约束 D = 默认值或 DEFAULT 约束 F = FOREIGN KEY 约束
FN = 标量函数 IF = 内嵌表函数 K = PRIMARY KEY 或 UNIQUE 约束
L = 日志 P = 存储过程 R = 规则 RF = 复制筛选存储过程
S = 系统表 TF = 表函数 TR = 触发器 U = 用户表 V = 视图 X = 扩展存储过程

举个小例子:
if exists(select * from tempdb.dbo.sysobjects where id= OBJECT_ID(N'tempdb.dbo.#tempa')) --是否存在该临时表
drop table #tempa --存在则删除
create table #tempa
(
Num int,
Name varchar(20) default '名字' --列的默认值设置
)
declare @a int
set @a = 1
while @a<30
begin
insert into #tempa (Num) values (@a)
set @a = @a+1
end
select * from #tempa
————————————————
版权声明:本文为CSDN博主「Richard_dzh」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Richard_dzh/article/details/45094951