SQL Server 2012 - Help

He probably queried a system database

doubt it, but he never confirmed if the table he created was under the master (which a new query defaults to if you don't select a database) or not.

at least he came right
 
OP is not using WHERE clause and you have a syntax error in your SQL (you can't use top n and * together in a select - top n means first n results, * means everything).

Just to correct a mistake here. You can do a "select top 1000 * from
" . The [top n] refers to the ROWS returned. The [*] refers to the COLUMNS returned. In other words "select top 1000 * from
" implies returning top 1000 rows and all the columns.
 
Yea, well. I was the only user on the database too since it was on my local machine and I was going to be doing some dev work on a restored database.

Turns out the database has 2 tables for each table, one under dbo. and the other on the sql login name. NO idea how that happened (or why anyone would want something like that) but still, out of experience, this is what happened and took 2 days to debug until I finally realized WTF was going on

You'll probably find your user account didn't have dbo as the default schema,
 
You'll probably find one ended up as dbo.tablename, and the other as yourname.tablename.

When you right click and select top 1000 it would have: select top 1000 * from dbo.tablename...

Then when you typed it out as select top 1000 * from tablename, it selected from yourname.tablename.

I did actually type it out as "select * from [OrdersDB].[dbo].[Customers]", still didn't work.
 
Top
Sign up to the MyBroadband newsletter
X