"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, July 28, 2010

Create backup of all database in sql server Query

 Hi friends,
It's simple to create backup of all database in the server 

SQl Query

DECLARE @name VARCHAR(50-- database name  DECLARE @path VARCHAR(256-- path for backup files  DECLARE @fileName VARCHAR(256) -- filename for backup 
DECLARE @fileDate VARCHAR(20-- used for file name
SET @path 'C:\Backup\' 
-- where i'm saving my back up

SELECT @fileDate CONVERT(VARCHAR(20),GETDATE(),112)
-- Fetching today's data
DECLARE db_cursor CURSOR FOR 
SELECT 
name FROM master.dbo.sysdatabases WHERE name NOT IN ('master','model','msdb','tempdb')
-- these database will be excluded

OPEN db_cursor   FETCH NEXT FROM db_cursor INTO @name  
WHILE @@FETCH_STATUS 0   BEGIN  
       SET 
@fileName @path + @name '_' @fileDate '.BAK'
-- file name comes here
       
BACKUP DATABASE @name TO DISK = @fileName 

       
FETCH NEXT FROM db_cursor INTO @name   END  

CLOSE 
db_cursor   DEALLOCATE db_cursor



Notes:
1.Create a folder with name Backup(whatever u giving in query) Otherwise it throw an error
2.Example of a backup file name:country_20100728.BAK
here Country_ is the database name and 20100728 means 2010-07-28 date when backup had created



Have a nice day... 'N happy Coding :)

Microsoft SQL Server 2008 Management and AdministrationMicrosoft SQL Server 2008 Internals (Pro - Developer)Beginning SQL Server 2008 for Developers: From Novice to Professional

Friday, July 23, 2010

Accessing Textbox (any asp.net ) Control on Edit Mode in Grid View

Hi friendz,
If you are working with GridView BoundField Columns and wanted to access the TextBox control on row editing for whatever reasons (which means when you click on the Edit link) then below is an example on how to do it.


Let say for example you need to change the BackColor of the TextBox on edit mode. So at  PreRender event of GridView, you can do something like this:

Code
protected void GridView1_PreRender(object sender, EventArgs e) {
                if (this.GridView1.EditIndex != -1) {
                    TextBox tb = (TextBox)GridView1.Rows[GridView1.EditIndex].Cells[1].Controls[0];
                    tb.BackColor = System.Drawing.Color.Blue;
                }
    }

 That's simple! I hope someone find this post useful!
Have a nice day... 'N happy Coding :)

ASP.NET Data Web Controls Kick StartProfessional DevExpress<sup><small>TM</small></sup> ASP.NET ControlsGridview, Style A, 12/bx 


How can i break line in message box?

This is the way to break the message:

MessageBox.Show (“This Text is displayed in First Line” & vbcrlf &
“This Text is displayed in Second Line”)

Have a nice day... 'N happy Coding :)

 Murach's JavaScript and DOM Scripting (Murach: Training & Reference)Professional JavaScript for Web Developers (Wrox Programmer to Programmer)JavaScript, A Beginner's Guide, Third Edition (Beginner's Guide (Osborne Mcgraw Hill))