如何避免在SQL中破坏语句 [英] how to avoid breaking of statement in sql
本文介绍了如何避免在SQL中破坏语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谢谢你
解决方案
检查表是否存在,并仅在不存在时创建.
如果 不 存在(选择 * 来自 dbo.sysobjects 其中 id = object_id(N ' [dbo].[table1]')和 对象属性(id,N ' 1 ) 开始 创建 表 ... END
嗨....
请尝试以下查询.
如果 object_id(' 销售" )是 不是 为空跨度> 创建 表销售 ( sno int , 名称 varchar ( 20 ) )
选择数据库
检查此条件表是否存在
(从sys.objects中选择*,其中object_id = object_id(''[dbo].[n_table]''))
然后
创建表
i have a query which is creating 4 tables.but in the database the first table is already exists not the further tables. when it comes to creation of first table,as the table exixts it is displaying as object already exists and coming out of query. but i want to create the rest of the tables.how can i avoid the breaking of query. Please help me
Thank You
解决方案
Check to see if the table exists and only create if it does not.
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[table1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) BEGIN CREATE TABLE ... END
Hi ....
Please try the below query.
If object_id('sales') is not null create table sales ( sno int, name varchar(20) )
hi,
select the database
check this condition the table exists or not
(select * from sys.objects where object_id = object_id(''[dbo].[n_table]'')
then
create table
这篇关于如何避免在SQL中破坏语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文