-- Use SSDT's SQL Server Unit Test -- Right-click on stored procedure > Create Unit Tests [TestMethod] public void GetActiveUsers_Test()
-- Right-click Stored Procedures > Add > Stored Procedure -- File: GetActiveUsers.sql CREATE PROCEDURE [dbo].[GetActiveUsers] @MinDaysSinceCreation INT = 0 AS BEGIN SET NOCOUNT ON; SELECT UserId, Username, Email, CreatedDate FROM [dbo].[Users] WHERE IsActive = 1 AND DATEDIFF(DAY, CreatedDate, GETUTCDATE()) >= @MinDaysSinceCreation ORDER BY CreatedDate DESC; END Pre-deployment (PreDeploymentScript.sql):
CREATE SECURITY POLICY Security.UserFilterPolicy ADD FILTER PREDICATE Security.tvf_securitypredicate(UserId) ON dbo.Users; Unit Testing:
Need help with a specific SSDT feature or deployment scenario?
# Build generates .dacpac file # Deploy using SqlPackage.exe: SqlPackage.exe /Action:Publish ` /SourceFile:".\YourFeatureDatabase.dacpac" ` /TargetConnectionString:"Server=localhost;Database=YourDB;Trusted_Connection=True" Compare Schemas:
Share your favourite memories with Sting and read other fans’ stories here.
Share your memorySorry, there was a problem uploading your memory - please try again later.
This entry has been added to the moderation queue and will appear on the site once approved.