How can I get a query of possible login names for SQL job owner? - sql

I'm trying to get the list of all possible login names for a job owner. The following query
SELECT * FROM sys.syslogins
WHERE hasaccess=1
gives me close to what I'm looking for but it returns additional login names that I do not find in the Browse Objects dialog box using SSMS (such as ##MS_AgentSigningCertificate## or BUILTIN\Administrators). I cannot find any logic in sys.syslogins table to discriminate those records. I looked in other logins tables but nothing comes closer than sys.syslogins.
SQL Server is version 10.50 (2008R2) but I'm looking for a query that will give me the results for this version or earlier.
What am I missing?

#Larnu pointed me in the right direction.
Query that solves my question is:
SELECT * FROM sys.server_principals
WHERE [type] IN ('S', 'U')

Related

SQL request Exceptions from *

If i create a sql database request with a * to get everything about one entry what do i have to do to get everything but one
for example: i want to have all information about the table article (ANR, BNR, BEZ, PC)(i don't want to have PC in it) so i start to write my request like this
SELECT a.*
FROM article a
In a select you can use * or specify all the columns you need, there's no way to extract everything but one:
SELECT ANR, BNR, BEZ
FROM article
Consider that using the *, even if it's shorter to write, may be dangerous, so I would only use it in simple check queries, and not in code to deploy.
Unfortunately there isn't a way to say 'select everything except...'.
I tend to go to the table in the object explorer, right click it and 'script as...' then choose 'SELECT To...' and new query window. It will then list all of the columns so you can remove the ones you do not want to select.
I should add, the above is only relevant for MSSQL and SSMS.

How to find Oracle SYSTEMDB Tables

I have an existing database and sql queries.
The query below works and returns rows.
Select * from systemdb.TABLE_A;
However when I tried to find the "TABLE_A" table using "Oracle SQL Developer", I cannot find it in the Tables or Views tree list.
Would like to ask where can I possibly find this table?
What is the meaning of "systemdb" keyword in the query above?
Thank you very much.
In that query SYSTEMDB is the name of a schema in the database. A schema is almost synonymous with a user.
In SQL Developer you are presumably logged in as a different user than SYSTEMDB. To see the tables belonging to SYSTEMDB you expand "Other Users" at the bottom of the tree, then you find SYSTEMDB and expand that one, and then you can find "Tables" or "Views" of the user SYSTEMDB.
It seems to be a tablespace / user created by PeopleSoft PeopleTools. There is not much to be found on it, but I found it here:
have to prepare 4 environmets with PeopleSoft... If there any documentation when you create SystemDB?

Login different to Login Name

I am currently working with SQL Server 2005 and I had the question arising whether you can have a Login with a different Loginname. I came to ask the question as the query
SELECT * FROM master.sys.syslogins
throws up, amongst others, the two columns "name" and "loginname" both displaying the same values.
So I asked myself if it was possible to have a Login called "XTest" where the user can actually log on with the Username "Test"...
No, it is not possible! Both columns have always the save value. You should not use sys.syslogins (in any database) at all in any current SQL Server version. This table is still provided for backward compatibility, use sys.server_principals and sys.sql_logins instead.

How to Query Database Name in Oracle SQL Developer?

How do I query the database name in Oracle SQL Developer? I have tried the following and they all fail:
SELECT DB_NAME();
SELECT DATABASE();
Why do these basic MySQL queries fail in SQL Developer? Even this one fails too:
show tables;
EDIT: I can connect to the database and run queries such as:
select * from table_name_here;
EDIT 2: The database type is Oracle, this is why MySQL queries are failing. I thought it was related to the database client not the database itself. I was wrong. I'll leave the question as is for other as lost as I was.
Once I realized I was running an Oracle database, not MySQL, I found the answer
select * from v$database;
or
select ora_database_name from dual;
Try both. Credit and source goes to: http://www.perlmonks.org/?node_id=520376.
try this:
select * from global_name;
You can use the following command to know just the name of the database without the extra columns shown.
select name from v$database;
If you need any other information about the db then first know which are the columns names available using
describe v$database;
and select the columns that you want to see;
I know this is an old thread but you can also get some useful info from the V$INSTANCE view as well. the V$DATABASE displays info from the control file, the V$INSTANCE view displays state of the current instance.
Edit: Whoops, didn't check your question tags before answering.
Check that you can actually connect to DB (have the driver placed? tested the conn when creating it?).
If so, try runnung those queries with F5
To see database name,
startup;
then type
show parameter db_name;
DESCRIBE DATABASE NAME; you need to specify the name of the database and the results will include the data type of each attribute.

Cannot see table in Object Explorer, SQL Server 2005/2008

This may be a dumb question. But I just received permissions to read/write to this DB. I see the tables of the DB, except for one. I can select from it, But I cannot see it in the Object Explorer. I restarted my computer, refreshed the object explorer and everything. Is there a restriction on viewing this table?
I"m so sorry I had to check the connection of the query. I was looking at two different versions of the same DATABASE. gosh. Should I take this question down?
The query
SELECT type, type_desc FROM sys.objects WHERE name = 'my_table_name'
should tell you what type of object your table really is.
Could it be a synonym, or a view? Check under the synonyms node and the views node. Also check the schema... if you are just saying SELECT * FROM table, try with SELECT * FROM dbo.table. It may be under a different schema.
You need to use the schema name in your create table query(eg. dbo.table name). By default it is getting created under your local server and hence it is available for you when you use the select query but once you check on server ita is not available.
When all else fails, right click on Tables and click Refresh.