Pages

Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Wednesday, April 11, 2012

AUTOMATIC BACK UP OF SQL 2008 EE DATABASE




Launch Management Studio and connect to the SQL server instance that contains the database that you want to back up. Right click on the database and then in the menu choose Tasks - Back up... This will open up a window where you can choose your backup options. Click on the "Script" button near the top and select the "Script Action to File" option. Save the File.
Now,ceate a Schedule Task to Run the Backup Script
a) Open up Windows Task Scheduler. b) Create a new Task using th

Tuesday, April 10, 2012

MSDB RECREATE IN SQL 2005

If your msdb goes suspect then you have two choices, restore it from a backup or recreate it (and then recreate any scheduled jobs). Obviously everyone has a comprehensive and valid set of backups, right? If only...
Of course, the very first thing you do is work out why it went suspect in the first place and take any necessary steps to stop it happening again.
Now you'd hope that if you don't have a valid msdb backup then you can at least run repair on it and so you don't lose everything in there. Well, that works as long as the transaction log isn't damaged. Ok, but then surely we can stick the database into the now-documented emergency mode (alter database dbname set emergency) and run emergency mode repair? (dbcc checkdb (dbname, repair_allow_data_loss) in emergency mode). Nope, msdb can't be put into emergency mode.
So, you're out of options and you're going to have to recreate msdb. Here's what to do (change the directory paths to suit your installation):

Tuesday, March 6, 2012

Creating Maintenance Plans in SQL Server 2008 R2

One of the repetitive task that DBA need to perform is create maintenance plan for database. Maintenance plans enables you to automate maintenance activities for a database, backups, db integrity checks and index maintenance tasks. We can easily create a maintenance plan using a wizard in sql server 2008 R2.

Monday, February 27, 2012

STEPS TO DELETE LOG FILE OF A DATABASE...

  • Backup the database
  • Detach the database, either by using Enterprise Manager or by executing : *Sp_DetachDB [DBName]*
  • Delete the transaction log file. (or rename the file, just in case)
  • Re-attach the database again using: *Sp_AttachDB [DBName]*
  • When the database is attached, a new transaction log file is created.

Wednesday, February 22, 2012

Some basic information about SQL




SQL ESSENTIALS

With just a dozen commands and functions, a developer is able to perform most activities related to querying and manipulating a database.
Commands  like  Select , insert , delete  , update , create    
Function  like   Sum ()  Avg ()  Max()  , Min() Count()
The SQL declarations, or commands, are divided into two main categories: DDL and DML
DDL, or data definition language, is the part of SQL used to define the data and objects in a database. When these commands are used, entries are made in a data dictionary in the SQL server. Following are some DDL commands:
Create Table-, Create  Index , Alter Table, Drop Table, Drop Index
DML, the language for manipulating data, is the part of SQL used to recover or manipulate data. Its commands are responsible for the queries and changes made to tables. These are some of the most important commands in this category:
Select , insert  ,  update  rollback

Data  Type  in SQL
Char
Character data type with fixed size of up to 254 characters.
Date
Stores only the date.
Datetime or Timestamp
When part of the input argument is omitted, SQLBase assumes the default 0, which converts the date to 30/12/1899 and 12:00 a.m.
Decimal or Dec
Supports up to 15 digits (999999999999999 to +999999999999999). If nothing is specified, the precision 5 and scale 0 are assumed.
Double precision
Numeric data type of floating-point and double precision.
Float
When the precision is between 1 and 21, the data type will have simple precision. Between 22 and 53, the precision is double.
Integer or Int
An integer data type with precision of up to 10 digits (2,147,483,648 up to + 2,147,483,647).
Long Varchar
Stores characters or binary objects. This is equivalent to the data type blob.
Number
This is a super set from other data types. It supports precision of up to 22 digits.
Real
Numeric data type of floating-point and simple precision.
Smallint
This data type has no fractional digits. The digits to the right of the decimal point are truncated. You can have precision of up to five digits (from 32,768 to +32,767).
Time
Stores only the hour.
Varchar
Character data type with fixed size of up to 254 characters.


Select command is the essence of the SQL language
Basic syntax:

SELECT [*] [ALL | DISTINCT]

[name =] expression

[expression [AS name]]

FROM [correlation_name]

WHERE

[GROUP BY ] ]

[HAVING ]

[ORDER BY [ASC] [DESC]] ]

Selects all the columns in a
table.

ALL
The default in a SELECT command is to recover all the rows.
DISTINCT
Does not show duplicated rows.
expression
A selection list of expressions separated by commas. An expression can be a column name, a constant, a checked variable, the result of a function, or a system keyword.
FROM
Contains the names of the tables or views resulting in a set of rows.
correlation_name

A related name can be used to designate a preceding table or view.
WHERE

Specifies a search condition for the basic tables or views. The search condition cannot contain aggregate functions.
GROUP BY

This clause groups the resulting rows of a query, according to the column names. When the column by which the grouping occurs is an expression with more than one column, you must specify the number that indicates its relative position in the selection list.
HAVING

This clause allows you to establish a search condition with a group of rows resulting from a GROUP BY clause or by grouped columns.
ORDER BY

Specifies the order of rows in a result table. The rows can be ordered by more than one column. When the order column is derived from a function or arithmetic expression, the column must be specified by an integer that indicates the relative number of its position in the SELECT command. Optionally, ASC or DESC, indicating the ascending or descending order, can follow each column name or number.


Instead of showing all the columns, you can request a       list of specific columns
This list must contain the names of the columns separated by commas. The order of the columns is not important. The code below selects the columns containing the first name, last name, and telephone number of each author.
 SELECT au_fname, au_lname, phone FROM authors;
Collected and prepared by S Jayachandran,

Scheduling of Database Backup in SQL Server 2008 Express

Scheduling of backups not possible in SQL server 2008 express editiion, because sql server agent is not present in SQL express eidition. The daily back up of database is important in post office environments. A disaster plan is the type of document you hope you never need. But a disaster plan is a key element of systems administration strategy because of the risk of disaster presented by hardware failures, natural catastrophes, network intrusions, and human error. The risk of disaster is particularly high for databases.

Simple tool for scheduling of database in SQL server 2008 can be downloaded from the following site

Remove row editing limitation in SQL2008



In SQL Server 2008 Management Studio Express , we can change the default settings that allows to edit more than the 200 rows at a time, or select more than 1000 rows.
To modify the “Edit Top 200 Rows” or “Select Top 1000 Rows” settings do the following:
1.Run the SQL Management Studio Express 2008
2.Click the Tools -> Options
3.Select SQL Server Object Explorer . Now you should be able to see the options
*Value for Edit Top Rows Command
*Value for Select Top Rows Command
4.Give the Values 0 here to select/ Edit all the Records
5.Now we can see the Edit All and Select All options on the table.

How to change the SQL sa password - For Security measure ( for SAs only)

How to change the SQL sa password in the SQL Server Enterprise Manager

To change the password on the 'sa' account from the graphical interfaces of MSSQL Server 7.0 and 2000 on both Windows NT 4.0 and 2000:

Quote:
1. Open the "SQL Server Enterprise Manager". This is usually under "Start"-->"Programs"-->"Microsoft SQL Server".

2. Navigate to the "Logins" object under the "Security" folder on the SQL Server you wish to administer. Then, right click on the 'sa' account and select "Properties".

3. Now, enter a new password in the "Password" field under the "Authentication" options.
Related Posts Plugin for WordPress, Blogger...

Blogroll