Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

problems using a database script

 
   Database Help (Home) -> General Discussions RSS
Next:  OpenForm code block: A better way?  
Author Message
WISEMANOFNARNIA

External


Since: Dec 25, 2008
Posts: 2



(Msg. 1) Posted: Thu Dec 25, 2008 12:04 pm
Post subject: problems using a database script
Archived from groups: comp>databases>ms-sqlserver (more info?)

I have a database at work. I scripted it to 3 files - one with users,
one with tables, and one with stored procedures. Then I took the
scripts home and tried to run them. The user script had statements
like:
Create User MyAdmin For Login MyAdmin with Default_schema[dbo]
This failed with the following error:
"MyAdmin is not a valid login or you do not have permission."
What login are they referring to? Are they using mixed mode
authentication?
Then I imported the tables and the stored procedures.
But the stored procedures were all underlined in red, and when I
hovered my mouse over a table name, it said the name was an invalid
object name. But when I checked the tables, there it was - it had
been created correctly.
The source version was sql server 2005, and the home version is sql
server 2008 express.
Any help is appreciated.
-- Marvin

 >> Stay informed about: problems using a database script 
Back to top
Login to vote
Erland Sommarskog2

External


Since: May 30, 2004
Posts: 2061



(Msg. 2) Posted: Thu Dec 25, 2008 6:29 pm
Post subject: Re: problems using a database script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

WISEMANOFNARNIA (COHENMARVIN@LYCOS.COM) writes:
> I have a database at work. I scripted it to 3 files - one with users,
> one with tables, and one with stored procedures. Then I took the
> scripts home and tried to run them. The user script had statements
> like:
> Create User MyAdmin For Login MyAdmin with Default_schema[dbo]
> This failed with the following error:
> "MyAdmin is not a valid login or you do not have permission."
> What login are they referring to? Are they using mixed mode
> authentication?

SQL Server has principals on two levels: 1) on the server level, where
they are commonly referred to as logins 2) on the database level, where
they are referred to as users.

There are two kinds of logins: SQL logins and Windows logins. An SQL
login is defined withing SQL Server itself, whereas an Windows login
is defined by Windows, and merely granted access to SQL Server, which
could be through a Windows group.

As long as we are talking about persons who log in to SQL Server,
to run queries in a database, they need to have a login in SQL Server
and somehow map to a user in the database. An SQL login must have a user
explicitly mapping to the login (unless the guest user is enabled),
whereas a Windows login again can be mapped implicitly.

However, a database user does not have to map to a login. There are
several ways this can happen. You can restore a database on a different
server. An SQL login has a SID which is unique to the server, so users
that maps to SQL logins will be orphaned on the new server. But it is
also possible to create a user and explicitly say WITHOUT LOGIN. This is
handy in a number of situations.

In your case you have script the database on server, and now you are
running the script on your own server. Obviously, you don't have all
logins your server at home that you have on your source server.

You can sort this out by creating these logins on your source servers.
If you don't plan to log in with any of these logins you could also
change the CREATE USER statements to use WITHOUT LOGIN.


> Then I imported the tables and the stored procedures.
> But the stored procedures were all underlined in red, and when I
> hovered my mouse over a table name, it said the name was an invalid
> object name. But when I checked the tables, there it was - it had
> been created correctly.

When you hovered and you created the tables? Even if you did, you may
need to refresh the Intellisense cache. There is a submenu for
Intellisense somewhere that has this command. There is also a keyboard
shortcut for it, I believe.


--
Erland Sommarskog, SQL Server MVP, esquel.RemoveThis@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 >> Stay informed about: problems using a database script 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
T-SQL script for tran log with - in database name - Hi, This is probably a trivial question, as I am simply trying to execute a BACKUP LOG database WITH NO_LOG. Except T-SQL will not accept anything I type when database has a - in it, for example data-base. I have tried: BACKUP LOG 'data-base' WITH..

Group by Problems - I know when you are using group by functions you have to include all the columns in the GROUP BY clause. But what I am having problems when using a case statement to determine whether to sum of not a column. eg. SELECT Country, Case WHEN Age<15 THE...

Problems when trying to rebuild indexex - Hello I am trying to rebuild indexes on our DB, but I am running into an error I am not able to solve. Server: Msg 1105, Level 17, State 2, Line 1 Could not allocate space for object 'ft' in database 'HastaDemo' because the 'PRIMARY' filegroup is full....

problems trying to import data from excel file - Hi I was trying to import an excel document into the excel file using the Import and Export Data wizard of MS SQL Server 2000 but when I do that, I seemed to get countless of rows with NULL values on every attribute. Furthermore i could not delete the....

Need a script to recreate scheduled jobs - I created a new database instance, but I forgot to script out the scheduled jobs before I wiped out the original database instance. I have attached the original msdb database as msdb_old onto the new instance, but I need a script to pull out the require...
   Database Help (Home) -> General Discussions All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]