English 中文(简体)
存储程序以及P、U、PC的类型
原标题:Stored procedure and where type in P, U, PC

我是SQL的初学者 我找不到这条线:

type in (N P , N PC )

是什么条款:P、PC、U?

编辑:

完整的查询是 :

IF EXISTS (SELECT * 
             FROM sys.objects 
            WHERE object_id = OBJECT_ID(N [dbo].SP_AUTHENTIFICATION] ) 
              AND type in (N P , N PC ))
最佳回答

首先是什么关系数据库管理系统?

然而,我怀疑 type 是表格中的一列或存储程序中的变量。

N ,意味着您将下一字符串重新转换为 nchar , nvarchar nvarchar2 (取决于 RDBMS)。这些数据类型允许多字字符。

PC P 是字符串。

将这些全部组合在一起, 您可以将 PC P 转换为多个字节字符集, 检查列或变量 type 是否与这些字符串之一相同 。

in 表示 type 可以是 PC P


根据您的评论使用 SQL- Server

您重新检查对象 < code> [dbo] 。 [SP_Authentiration] 是否存在,并且是一个存储程序(P)或组装存储程序(PC)。

type type 列在 sys.objects 不是 nchar ,所以转换毫无意义。

点点一行进

  • IF EXISTS - If the result of the following query in brackets returns a row:
  • SELECT * FROM sys.objects - Select a row from sys.objects
  • WHERE object_id = - Where the object_id is equal to the following
  • OBJECT_ID(N [dbo].[SP_AUTHENTIFICATION] ) - Return the object_id of [dbo].[SP_AUTHENTIFICATION]
  • AND type in (N P , N PC ) - and where that object is a stored procedure.

U ,不在您的查询中,它正在检查 type 是否是一个表格。 文档 提供完整的列表。

问题回答

如果您希望您的问题对其他人有用,评论意见中的详细内容属于问题正文,因为这些识别符号只有在 sysobbjects 表格中才有意义。

这就是意义所在。

  • U - user table
  • P - traditional stored procedure (SQL)
  • PC - CLR stored procedure (usually C# or VB.NET)

因此,您的条款会检查是否存在任何名为 sp_authetication 的程序。

该行正在寻找一个名为 SP_Authentenization 的存储程序, 如果它存在, 可能会丢弃它。 这在 SQL 服务器中非常常见, 因为 SQL 服务器没有 CreateOrAlter 。

我找到了更好的方法 来运行一个创建OrAlter, 这样历史就可以保存在存储程序上。

if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N [dbo].[myproc] ) AND type in (N P , N PC ))
  exec( create proc dbo.myproc as select 0 )

alter proc dbo.myproc

as

...




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签