database free space

select name, filename, CONVERT(decimal(12,2),round(a.size/128.000,2))as FileSizeMB, CONVERT(decimal(12,2),round(fileproperty(a.name,’SpaceUsed’)/128.000,2))as SpaceUsedMB, convert(decimal(12,2),round((a.size-fileproperty(a.name,’SpaceUsed’))/128.000,2))as FreeSpaceMB from dbo.sysfiles a

execute as

CREATE PROCEDURE dbo.usp_Demo WITH EXECUTE AS ‘SqlUser1’ AS SELECT user_name(); — Shows execution context is set to SqlUser1. EXECUTE AS CALLER; SELECT user_name(); — Shows execution context is set to SqlUser2, the caller of the module. REVERT; SELECT user_name(); — Shows execution context is set…

grant vs revoke vs deny

https://www.mssqltips.com/sqlservertip/2894/understanding-grant-deny-and-revoke-in-sql-server/ Grant – gives perms GRANT SELECT ON OBJECT::Test.TestTable TO TestRole; Revoke- undoes perms whether it’s grant or deny REVOKE SELECT ON OBJECT::Test.TestTable FROM TestRole; Deny – blocks access and trumps all other access DENY SELECTONOBJECT::Test.TestTable TO TestUser;   — Query sys.database_permissions to see applicable permissions…

Set or Change Column Collation

http://msdn.microsoft.com/en-us/library/ms190920.aspx   You can override the database collation for char, varchar, text, nchar, nvarchar, and ntext data by specifying a different collation for a specific column of a table and using one of the following: The COLLATE clause of CREATE TABLE and ALTER TABLE. For…