久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SCHEMA_NAME() 返回 NULL

SCHEMA_NAME() returns NULL(SCHEMA_NAME() 返回 NULL)
本文介紹了SCHEMA_NAME() 返回 NULL的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在 T-SQL 腳本中使用 SCHEMA_NAME() 函數(shù).

它為我返回 NULL,但為我的同事返回默認架構.

SCHEMA_NAME() 的文檔僅將 NULL 列為可能的值,同時還為 SCHEMA_NAME() 函數(shù)提供了一個參數(shù).

以下是 SCHEMA_NAME() 的文檔:https://docs.microsoft.com/en-us/sql/t-sql/functions/schema-name-transact-sql

在調(diào)試這個問題時我應該尋找什么?

DBA 已檢查我的同事和我自己的權限是否相同.

我在不帶任何參數(shù)的情況下調(diào)用該函數(shù),因此文檔中聲明的在 schema_id 無效時返回 NULL 的情況不適用 - 至少沒有明確說明.

DBA 確認我有一個默認架構,我使用以下選擇來確認我有一個默認架構:

select * from sys.database_principles dp where dp.name = USER_NAME();

DBA 將我的默認架構更改為其他內(nèi)容,然后將其更改回來以防后臺設置了某些內(nèi)容.

這發(fā)生在 SQL Studio 中以及當我使用 sqlcmd 在命令行上運行時.

我注意到當我運行 CREATE PROCEDURE myproc 過程是在我的默認架構中創(chuàng)建的,但是當我運行 execute myproc 我需要做 executemyschema.myproc.即:我必須指定架構.

我已通過在調(diào)用存儲過程中硬編碼架構名稱來驗證默認架構是否存在.

解決方案

當您在與 schema_id 不同的數(shù)據(jù)庫上執(zhí)行查詢時,也會發(fā)生這種情況

例如

select sn = schema_name(schema_id) from [yourdbname].sys.all_objects

并且當前數(shù)據(jù)庫不是 [yourdbname]

I am using the SCHEMA_NAME() function in a a T-SQL script.

It returns NULL for me, but the default schema for my colleague.

The documentation for SCHEMA_NAME() only lists NULL as a possible value when one also supplies an argument to the SCHEMA_NAME() function.

Here is the documentation for SCHEMA_NAME(): https://docs.microsoft.com/en-us/sql/t-sql/functions/schema-name-transact-sql

What should I look for when debugging this problem?

The DBA has checked that my permissions are same for my colleague and myself.

I am calling the function without any arguments so the documentation's stated case of returning NULL when schema_id is not valid does not apply -- at least not explicitly.

The DBA confirmed I have a default schema and I used the following select to confirm I have a default schema:

select * from sys.database_principles dp where dp.name = USER_NAME();

The DBA changed my default schema to something else, then changed it back in case there is something set in the background.

This happens in SQL Studio and when I run on the command line using sqlcmd.

I have noticed that when I run CREATE PROCEDURE myproc the procedure is created in my default schema, but when I run execute myproc I need to do execute myschema.myproc. That is: I must specify the schema.

I have verified that the default schema exists by hard coding the schema name in the call to the stored procedure.

解決方案

This can also happen when you are performing query on a different database than the schema_id

e.g.

select sn = schema_name(schema_id) from [yourdbname].sys.all_objects 

and the current database is not [yourdbname]

這篇關于SCHEMA_NAME() 返回 NULL的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 午夜黄色| 在线欧美| 伦理午夜电影免费观看 | 91av小视频| 91视频久久 | 伊人伊人伊人 | 日本 欧美 三级 高清 视频 | 日本人做爰大片免费观看一老师 | 涩涩视频网站在线观看 | 久久精品91久久久久久再现 | 精产国产伦理一二三区 | 欧美日韩在线播放 | 日韩视频在线播放 | 欧美毛片免费观看 | 一区二区三区 在线 | 日韩视频―中文字幕 | 国产精品久久久久久久久久 | 日韩一二三 | 久久精品国产久精国产 | 天天看逼| 欧美日韩综合 | 高清亚洲 | 超碰在线播 | 91免费看片神器 | 欧美日韩视频 | 久久综合影院 | 国产成人av免费看 | 午夜大片 | 一二三四在线视频观看社区 | 免费视频一区二区 | jlzzjlzz欧美大全 | 97视频免费| 日本中文字幕一区 | 九一视频在线观看 | 一级黄色毛片免费 | 色综合久久久久 | a毛片| 精品国产99| 久久久免费 | 自拍视频在线观看 | 综合网在线 |