Monday 31 March 2014

Shrink Log File In Sql Server 2008

To Know About DataBase Size

sp_helpdb "dbname"
GO


--Then Execute this query
ALTER DATABASE "dbname"
SET RECOVERY SIMPLE;
GO


-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (dblogfilename,1);
GO






-- To Know About Dblogfilename
SELECT file_id, name
FROM sys.database_files;
GO



DBCC SHRINKFILE (1, TRUNCATEONLY);

Thursday 13 March 2014

SQL Server Procedures, tables and triggers

  • To Know about the details of Procedure: 
    • sp_helptext yourprocedurename 
  • To Know about the List of all Procedure in  a particular database: 
    • select * from sysobjects where xtype='P'
  • To Know about the List of all tables in  a particular database: 
    • select * from sysobjects where xtype='U'
  • To Know about the List of all trigger in  a particular database: 
    • select * from sysobjects where xtype='tr'
  • To Know about the List of all trigger on particular table: 
    • sp_helptrigger yourtablename
  • Enable/Disable Trigger
    • ALTER TABLE table_name DISABLE TRIGGER tr_name 
    • ALTER TABLE table_name ENABLE TRIGGER tr_name