19
Using Windows 7 Ultimate, after installation of SQL Server 2005, an error occurrs regarding Connection. (Settings for Database Engine) Login failed for user 'Admin\vilas'. (Microsoft SQL Server, Error : 18456) To resolve this error please follow the steps given below: Set Security Permissions for SQL Server 2005---Properties.

Create Database Permission Denied

Embed Size (px)

Citation preview

Page 1: Create Database Permission Denied

Using Windows 7 Ultimate, after installation of SQL Server 2005, an error occurrs regarding Connection. (Settings for Database Engine)Login failed for user 'Admin\vilas'. (Microsoft SQL Server, Error : 18456) 

        

To resolve this error please follow the steps given below:

Set Security Permissions for SQL Server 2005---Properties.

Page 2: Create Database Permission Denied
Page 3: Create Database Permission Denied
Page 4: Create Database Permission Denied

Select Security tab and give the permissions for user name.

Run SQL Server 2005 --- now the System has been given a server name by default and loads SQL Server 2005 successfully. 

Page 5: Create Database Permission Denied

Enjoy database creation in SQL Server 2005.

CREATE DATABASE Permission Denied - SQL Express 2005 Problem and SolutionToday I installed SQL Express 2005 on my Windows Vista PC and a SQL Server Express 2005 instance with the name GopinathMPC\SQLExpressis created successfully.

As a first step of using the new SQL Server Express 2005 I started creating a database with the query

CREATE DATABASE TestDB

GO

Unexpectedly execution of the above query failed with the following error message

Page 6: Create Database Permission Denied

Msg 262, Level 14, State 1, Server GOPINATHM-PC\SQLEXPRESS, Line 1 CREATE DATABASE permission denied in database 'master'.

The error message indicates that I don't have enough permissions to create the database. The login which I'm using to access my Windows Vista has administrative privileges, but still I'm not granted administrative privileges on the SQL Server instance.

Looking through the documentation of SQL Server Express, I found the that

Windows Vista users that are members of the Windows Administrators group are not automatically granted permission to connect to SQL Server, and they are not automatically granted administrative privileges.

Now it is very clear that event though I'm an administrator on my Windows Vista OS I don't have administrative rights on SQL Express 2005 Server. So I need to get administrative rights.

How to Grant Administrative Rights on SQL Express 2005?

1. Log in to Windows Vista using your administrative account2. Open SQL Server Surface Area Configuration Application ( Start --> All

Programs --> Microsoft SQL Server 2005 --> Configuration Tools -->SQL Server Surface Area Configuration)

3. Click on Add New Administrator (pointed in the image) link

Page 7: Create Database Permission Denied

4. A new window with title 'SQL Server User Provisioning on Vista' popup and displays the permissions on the left panel.

5. Select the permission 'Member of SQL Server SysAdmin role on SQLEXPRESS' available on the left panel and add it to the right panel with the help of add button( button with > text) available in the window.

6. Click on OK button to save the changes.7. That's all now your Windows login has administrative privileges on SQL

Server.

Perbedaan Char, Varchar dan nVarchar

Tipe data Char adalah tipe data karakter yang panjangnya tetap (fixed-length). Jadi ketika kita misalnya membuat tabel dan mendeklarasikan suatu tipe data Char dengan panjang 5 karakter. Maka SQL Server akan mengalokasikan memori pada media penyimpanan sebanyak panjang karakter yang kita deklarasikan. Walaupun nantinya ketika terjadi penambahan atau perubahan data pada tabel tersebut panjang karakternya kurang dari 5, SQL server akan tetap menyimpannya dengan panjang 5 karakter. Jika kita melihat kasus tadi, dimana data yang kita masukkan panjang karakternya kurang dari panjang karakter yang telah kita deklarasikan sebelumnya maka SQL server akan menambahkan karakter kosong atau spasi dibelakang. Sebagai contoh, misalkan deklarasi tipe data suatu field/kolom pada sebuah tabel adalah char(5), lalu ketika terjadi penambahan atau perubahan, data yang akan kita masukkan panjang karakternya hanya 3, SQL Server akan tetap menyimpan data dengan panjang 5 karakter untuk data itu dengan menambahkan 2 buah karakter kosong dibelakangnya. Akan tetapi jika panjang karakter dari data

Page 8: Create Database Permission Denied

yang akan kita simpan melebihi panjang dari karakter yang kita deklarasikan maka SQL server akan memberikan pesan error dan data tidak bisa disimpan.

Lalu bagaimana dengan tipe data Varchar. Tipe data Varchar adalah tipe data karakter yang panjangnya tidak tetap (variable-length). Mungkin bisa dibilang kebalikan dari tipe data Char. SQL server akan mengalokasikan memori pada media penyimpanan sepanjang karakter yang akan kita simpan. Misalnya kita membuat tabel dengan mendeklarasikan suatu field/kolom dengan tipe data Varchar dengan panjang 15 karakter, maka SQL server tidak akan serta merta mengalokasikan 15 karakter pada setiap kali terjadi penambahan atau perubahan data, akan tetapi dia akan melihat terlebih dahulu panjang karakter dari data akan kita simpan. Misalkan data yang kita simpan panjang karakter nya hanya 5, maka SQL server hanya akan mengalokasikan 5 karakter pada media penyimpanan, tidak 15 karakter. Lalu bagaimana jika kita menyimpan data yang karakter nya lebih panjang dari karakter yang kita deklarasikan pada field/kolom yang kita buat pada tabel. Seperti contoh diatas kita mendefinisikan suatu field/kolom dengan tipe data Varchar sepanjang 15 karakter dan ketika terjadi perubahan data panjang karakternya lebih dari itu, biasanya sih SQL Server akan menghasilkan pesan error dan data tidak dapat disimpan.

Kalo dengan Nvarchar perbedaan nya hanya dari kemampuannya menyimpan kumpulan karakter. Varchar untuk menyimpan karakter bersifat non-unicode dan Nvarchar untuk karakter yang bersifat unicode. Unicode dapat diartikan memiliki kemampuan untuk menyimpan karakter dari bermacam-macam bahasa di dunia sedangkan unicode hanya berdasarkan setting bahasa komputer lokal. Jadi apabila kita akan membuat aplikasi yang akan digunakan untuk orang diseluruh dunia maka disarankan untuk menggunakan tipe data Nvarchar. Karena terdapat perbedaan diantara alphabet yang ada didunia, seperti misalnya eropa yang relatif lebih kecil atau mungkin kanji atau pun alphabet korea yang mempunyai bentuk yang khusus.

ref: http://www.combromania.net/tipe-data-char-varchar-dan-nvarchar-sql-server-2000

Page 9: Create Database Permission Denied

How to backup and restore database on Microsoft SQL Server 2005MS SQL Server, WindowsJanuary 12th, 2008

Introduction

This post will give you a brief introduction of SQL Server backup. As

we know, SQL Server backup software is springing up nowadays. Take EaseUS Todo Backup

Advanced Server as an example, it’s an all-in-one SQL server backup software for MS SQL

Server 2000/2005/2008, exchange server and server 2000/2003/2008, and provides proven

database backup solution for Server administrators.

But in the example below, I will show a step-by-step database backup from SQL Server 2005

and restore the database to another SQL Server 2005 Express Edition using Microsoft SQL

Server Management Studio.

Step-by-step

Backup a database.

Now I will backup AdventureWorks database on BKKSQL2005 which runs Microsoft SQL

Server 2005 to a file.

1. Connect to source server. Open Microsoft SQL Server Management Studio and

connect to BKKSQL2005.

Page 10: Create Database Permission Denied

2. Right-click on the AdventureWorks database. Select Tasks -> Backup…

3. On Back Up Database window, you can configure about backup information. If you’re

not familiar these configurations, you can leave default values. Here are some short

descriptions.

1. Database – a database that you want to backup.

2. Backup type – you can select 2 options: Full and Differential. If this is the first

time you backup the database, you must select Full.

3. Name – Name of this backup, you can name anything as you want.

4. Destination – the file that will be backup to. You can leave as default. Default

will backup to “C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\

Backup”.

5. Click OK to proceed backup.

Page 11: Create Database Permission Denied

4. Wait for a while and you’ll see a pop-up message when backup is finished.

5. Browse to the destination, you’ll see a backup file (.bak format) which you can copy

to other server for restore in the next step. Default backup directory is “C:\Program

Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup”.

Page 12: Create Database Permission Denied

Restore the database.

Next, I will restore the AdventureWorks database from a file that I’ve created above to

BK01BIZ001 which runs Microsoft SQL Server Express Edition.

1. Copy the backup file from source server to destination server. I’ve copied into the

same directory as source server.

2. Connect to destination server. Open Microsoft SQL Server Management Studio

Express and connect to BK01BIZ001.

3. Right-click on Databases. Select Restore Database…

Page 13: Create Database Permission Denied

4. Restore Database window appears. On Source for restore, select From device and

click [...] buttton to browse file.

Page 14: Create Database Permission Denied

5. On Specify Backup, ensure that Backup media is “File” and click Add.

Page 15: Create Database Permission Denied

6. On Locate Backup File, select the backup file. This is the backup file that was created

in Backup a database section and was copied to this server. Click OK. OK.

7. Back to Restore Database window.

1. On Destination for restore, select “AdventureWorks”.

Note: If you haven’t added the backup file on Source before (step 4-6), you

won’t see the database name on Destination.

2. On Source for restore, check the box in front of the backup name (in Restore

column).

3. Click OK.

Page 16: Create Database Permission Denied

8. Wait until restore finish and there’ll be a pop-up message notify.

Page 17: Create Database Permission Denied

9. Now you’ll see the restored database on the destination SQL Server.