Can someone explain WITH (1)? - sql-server-2008

I am working on upgrading from SQL Server 2008 to 2016 and I fixed the following SQL. Is this a table hint with the index? I want to understand what is happening:
FROM u_SAMPLE_SA WITH (1)

Related

Microsoft SQL resetting ID auto increment

I am using Microsoft SQL server 2012 and i am trying to reset my table primary key IDs so its in a sequential manner, i know some will say its better to leave it as it is but i just want to find out a way to do it.
Question edited due to extra knowledge gained within the first 10mins of post
This is the command to use in SQL Server 2008, and should be the same for 2012:
Reset autoincrement in Microsoft SQL Server 2008 R2
DBCC CHECKIDENT ("YourTableNameHere", RESEED, 1);
And it's not very clear if you want it in MySQL or T-SQL syntax.

Is there a LookupSet equivalent in SQL Server 2008 ... NOT r2?

Just spent the day figuring out how to properly use the LookupSet method only to find out it isn't supported on my production database which is NOT running SQL Server 2008 R2 (it is just running ol' SQL Server 2008).
So, is there a way to re-produce the functionality so it will work with old SQL Server 2008?
Thanks - wg
As Gordon Linoff points out in the comments, this can usually be implemented in the SQL query. If the datasource for your target of the LookupSet is similar enough to the the main query, then you can accomplish this with a Common Table Expression or a correlated subquery in SQL.
Your could write custom code - which I wouldn't recommend because it's probably simpler to combine the data relationally first in your query. If one of the data sources is non-relational, then use SSIS to get it into a table and then use a query to combine the two sets of data.

Alternative queries equivalent to Oracle's Analyze Table Query

Are there queries in other databases equivalent to Oracle's very useful ANALYZE TABLE.. ? I am looking for alternatives for the following Database vendors:
MySQL
MS SQL Server [2000, 2005, 2008]
Thanks in advance
MySQL has ANALYZE TABLE as well, see here:
http://dev.mysql.com/doc/refman/5.5/en/analyze-table.html
Have a look at SQLServer-DBA.com at this page for a statistics overview and another page on how to gather statistics in MS SQL Server. I don't know of other vendor implementations.
Further research shows that SQL Server has the CREATE STATISTICS command, which looks to be the equivalent.

My SQL table is missing mysteriously

On the live server a table was not found mysteriously. I twas working normally but suddenly i got sql error of missing table. I looked through phpmyadmin i found that a table was really missing mysteriously. It happened first time in my MYSQL life.
Can you please tell me what happened, why the table vanished mysteriously?
Maybe a SQL injection attack dropped the table? Have you checked the database logs?

SQL Server 2008 Upgrade/compile - Column Alias and Table Alias

One of databases I develop for is being upgraded to SQL 2008 (from SQL 2000).
The upgrade advisor is flagging an issue that I don't think is an issue. I was hoping that there is documentation that this is a known issue so that my DB team will just let it pass.
The error is saying that in SQL 2008 you cannot use a table alias and a column alias together. It also says that the sprocs that use these will not compile.
Here is the different SQL Scenario's that are causing this:
select
case
when tblOneAlias.COLUMN_NAME is null then tblTwoAlias.COLUMN_NAME
else tblOneAlias.COLUMN_NAME
end as COLUMN_NAME
from tblOne tblOneAlias
join tblTwo tblTwoAlias
on tblOneAlias.JOIN_VALUE = tblTwoAlias.JOIN_VALUE
order by tblOneAlias.COLUMN_NAME, tblTwoAlias.COLUMN_NAME
select tblAlias.COLUMN_NAME as 'COLUMN_NAME'
from tblName tblAlias
order by tblAlias.COLUMN_NAME
select COLUMN_NAME = tblAlias.COLUMN_NAME
from tblName tblAlias
order by tblAlias.COLUMN_NAME
In each scenario an alias is created that matches the actual column name (not usually a good idea I agree).
However, they compile just fine in SQL 2008 (with compatibility level set to 10). I think the Upgrade Advisor is just confused because the alias is the same as the column name. I agree that there is some "less than desireable code" here. But I don't think it needs to be changed to upgrade to SQL 2008.
The fewer things we can change with this upgrade means the fewer things to look into if something breaks when when we roll out to production.
If anyone knows of any documentation saying this is a known limitation then please let me know.
Also, if I am wrong and these are not allowed in SQL 2008 somehow (though they compile just fine) then I would also like to know it.
Thanks...
From what I initially read only a column alias in the ORDER BY caluse can't be prefixed by a table alias and this will cause Upgrade Advisor to complain. If you capture a trace of the workload using Profiler, UA can analyze the tracefile and identify the offending SQL so you know where/what to fix.
I've also read that it does not seem to be an issue anymore and was possibly fixed but this hasn't been confirmed by MS from what I could find.
Hope this helps!