I am using SQL server 2008 Express R2. I was trying to test a couple of queries when i started getting this error:
Msg 2760, Level 16, State 1, Line 2
The specified schema name "t_one" either does not exist or you do not have permission to use it.
SQL:
CREATE TABLE t_one.clients
(
t_id int NOT NULL PRIMARY KEY IDENTITY,
colOne varchar(255) NOT NULL,
colTwo varchar(255) NOT NULL,
colThree varchar(255) NOT NULL,
colFour varchar(255) NOT NULL,
CONSTRAINT pk_testID PRIMARY KEY(t_id)
)
I granted permissions to my user profile just using the interface and after i clicked OK/save it didn't apply them - when I went back to the permissions for my user they were all unchecked again.
Step 2: Right click “Login” and select the user account under which you want to create the database. Step 3: Right click and select properties tab. Step 4: Under “Server Roles” tab, select “dbcreator” checkbox. Step 5: Click “OK” and try to create database in the user account.
Right-click a stored procedure and select Properties. In the Stored Procedure Properties -stored_procedure_name dialog box, under select a page, select Permissions. Use this page to add users or roles to the stored procedure and specify the permissions those users or roles have.
Right-click on Logins and select New. Enter the username. To set permissions, double-click the user account and do one of the following: If you are using SQL Authentication, enter the user name.
Try to run it this way:
CREATE SCHEMA t_one
CREATE TABLE t_one.clients
(
t_id int NOT NULL PRIMARY KEY IDENTITY,
colOne varchar(255) NOT NULL,
colTwo varchar(255) NOT NULL,
colThree varchar(255) NOT NULL,
colFour varchar(255) NOT NULL,
CONSTRAINT pk_testID PRIMARY KEY(t_id)
)
To check and create if the schema does not exist, you can have the following running in a separate batch
IF NOT EXISTS ( SELECT *
FROM sys.schemas
WHERE name = N't_one' )
EXEC('CREATE SCHEMA [t_one] AUTHORIZATION [dbo]');
GO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With