随笔 - 58  文章 - 14 评论 - 10 trackbacks - 0
<2008年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

与我联系

搜索

 

常用链接

留言簿

我参加的小组

随笔档案(58)

文章分类(11)

Watch

最新评论

  • 1. re: APACHE+ASP.NET 出现问题
  • 发现原来不是apache的原因,/joe/后面的那一串字符是sessionid,在web.config中sessionState的cookieless设置为UseUri就回出现这个问题。 这几天都在...
  • --josephshi
  • 2. re: compiere/adempiere+pgsql8.2+RHEL4+jdk1.5
  • compiere是不支持postgresql的,只支持postgresql plus AD server。adempiere是支持oracle postgresql的,若在linux下使用postgr...
  • --yuzifu

阅读排行榜

评论排行榜


The Object_ID() function in SQL Server can be utilised in a number of ways. One such utility is to verify if an object exists.

The Object_ID() takes in the object name and object type as parameters. The object name is the object used and the object type is the type of object used in a schema.

For example to check if a table exists in a database, use this query :

IF OBJECT_ID ('AdventureWorks.dbo.AWBuildVersion','U') IS NOT NULL
Print 'Table Exists'
ELSE
Print 'Table Does Not Exists'

where 'AdventureWorks.dbo.AWBuildVersion' is the object name and 'U' is the object type which represents a table

Similarly you can check for a stored procedure or a view by specifying the correct object type. You can get an entire list of object types over here.

To check if a database exists, you can use the DB_ID() function as shown below :

IF db_id('AdventureWorks') IS NOT NULL
Print 'Database Exists'
ELSE
Print 'Database Does Not Exists'

posted on 2008-04-02 13:42 josephshi 阅读(209) 评论(0)  编辑 收藏

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      


相关链接: