Posts

Showing posts from January, 2011

Recover the Database in SQL SERVER

1.create the Database with same Name,MDF Name,LDF Name. 2.Stop the Sql Server and then Replace the only new MDF file by old database (Corrupted database) MDF file and delete the LDF File of newly created database. 3.Now Start the Sql Server again. 4.you can notice that database status became 'Suspect' as expected. 5.Then run the given script to know the current status of your newly created datatbase. (Better you note it down the current status) SELECT * FROM sysdatabases WHERE name = 'yourDB' 6.Normally sql server would not allow you update anything in the system database.SO run the given script to enable the update to system database. sp_CONFIGURE 'allow updates', 1 RECONFIGURE WITH OVERRIDE 7.After run the above script, update the status of your newly database as shown below. once you updated the status, database status become 'Emergency/Suspect'. UPDATE sysdatabases SET status = 32768 WHERE name = 'yourDB' 8.Restart SQL Server (This is must, i

Reflect in the view after Edited or Newly Added column of a Table

Image
After changed the name or add new column in the table, that changes would not reflect in the view if that field used in that view. For that you just run this system stored procedure with view name as parameter rather open the view and update it. Sp_refreshview yourviewname For an Example: I am using Table_A, Table_B and View_C In the View C I have used Table A and Table B. After created the View C I added one more column call Status in the Table A and run the View C, you would not see that newly added column as view have not been refreshed yet as shown below. For this you can simply update the view just using the above stored procedure as shown below, Sp_refreshview View_C After run the script you can able to see that added column in the view as shown below,