NS<SubscriptionClassName>View
提供相關訂閱類別的訂閱記錄檢視。Notification Services 會利用下列命名慣例,每個訂閱類別各建立一份檢視:NSSubscriptionClassNameView。
例如,Notification Services 所檢附的 Stock 範例有兩個訂閱類別:StockSubscriptions 和 PortfolioSubscriptions。相關的檢視稱為 NSStockSubscriptionsView 和 NSPortfolioSubscriptionsView。
![]() |
---|
您可以將使用簡式動作的事件驅動訂閱插入這份檢視中。您不能插入已排程之訂閱或使用條件動作的訂閱。 |
檢視資料行
下表顯示 NSSubscriptionClassNameView 檢視所包含之每項訂閱的相關資訊。
資料行 | 資料類型 | 描述 |
---|---|---|
SubscriptionId |
bigint |
IDENTITY 資料行。如果將資料插入這份檢視,SubscriptionId 值必須是 NULL。 |
SubscriberId |
nvarchar(255) |
訂閱的訂閱者識別碼。 |
Created |
datetime |
建立訂閱記錄的日期和時間。請勿將值插入這個資料行中。 |
Updated |
datetime |
更新訂閱記錄的日期和時間。請勿將值插入這個資料行中。 |
Enabled |
nvarchar(8) |
如果值是已啟用,便會啟用訂閱,且可以產生通知。 |
Schedule (只限已排程的訂閱) |
nvarchar(2048) |
如果訂閱類別支援已排程的訂閱,這個資料行便會出現,且會顯示這項訂閱已排程的規則之執行排程。如果利用這份檢視來插入訂閱,這個值必須是 NULL。 |
Subscription_class_field_name (1-n) |
application-defined |
訂閱類別中所指定的所有資料行也會出現在這份檢視中。您不能利用這份檢視來插入條件動作。 |
備註
NSSubscriptionClassNameView 檢視位在應用程式資料庫中。
權限
系統管理員 (sysadmin) 和 db_owner 伺服器角色的成員,以及 NSAnalysis 和 NSSubscriberAdmin Notification Services 資料庫角色的成員,都可以使用這份檢視的 SELECT 權限。INSERT、UPDATE 和 DELETE 權限則會授與 NSSubscriberAdmin 資料庫角色。
範例
下列查詢會從 NSSubscriptionClassNameView 檢視中,選取識別碼、狀態、裝置名稱和地區設定資料行:
USE StockInstanceStock;
GO
SELECT SubscriberId, Enabled, DeviceName, SubscriberLocale
FROM NSStockSubscriptionsView
ORDER BY SubscriberId;
GO
下列查詢會將訂閱插入 NSWeatherSubscriptionsView 中:
USE TutorialWeather;
GO
INSERT INTO NSWeatherSubscriptionsView
(SubscriberId, Enabled, DeviceName, SubscriberLocale, City)
VALUES
(N'TestUser1', N'Enabled', N'Work e-mail', N'en-US', N'Phelphs');
GO