I have 3 databases sytemdatabases
,smoketest
and learnqueries
.
Every time i write and execute create table query (create table tablename (colname datatype(size)))
, a new table is created in the systemdatabases
.
I need it to be created to smoketest database.
I tried on this query (create table smoketest.newtablename(number int,name varchar(50));
It is showing an error (Msg 2760, Level 16, State 1, Line 1
The specified schema name "smoketest" either does not exist or you do not have permission to use it.) when i executed it.
It says 2 chances
Pls help
The 4 part 'dot' notation in Sql Server for tables is
Server.Database.Schema.Object
So you would need to create the table with at least 3 parts if smoketest
is not the current database on your connection, e.g. if you are on master
, and assuming you want the new table in schema dbo
:
create table smoketest.dbo.Tablename(ID INT)
Alternatively, switch to the smoketest
database and create the table with 1 or 2 part naming:
use smoketest
GO
create table dbo.Tablename(ID INT)
GO
USE smoketest
GO
create table newtablename(number int,name varchar(50));
If you have a permission issue, check out this SQL Server 2008: how do I grant privileges to a username?
Hope this helps.
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