SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Would like Syntax Error Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

viperbyte
Posting Yak Master

USA
132 Posts

Posted - 12/06/2012 :  14:57:11  Show Profile  Reply with Quote
Hi guys.

Can someone super please take a look at this and tell me how to correct the error. I get a red squigly line on the line mentioned in the script below. I get a message that says "Syntax error near 'wait_time_ms'.

--capture point-in-time
SELECT wait_type, waiting_tasks_count,
wait_time_ms, max_wait_time_ms,
signal_wait_time_ms
INTO #OriginalWaitStatSnapshot
FROM sys.dm_os_wait_stats;

--wait for X amount of time
WAITFOR DELAY '00:00:02';

--Collect again
SELECT wait_type, waiting_tasks_count,
wait_time_ms, max_wait_time_ms,
signal_wait_time_ms
INTO #LatestWaitStatSnapshot
FROM sys.dm_os_wait_stats;

--compare the results
SELECT 1.wait_type,
(1.wait_time_ms - O.wait_time_s) accum_wait_ms --red squigly line under wait_time_ms on this line
FROM #OriginalWaitSnapshot O
INNER JOIN #LatestWaitStatSnapshot 1 ON
O.wait_type = 1.wait_type
WHERE 1.wait_type_ms > O.wait_time_ms
ORDER BY 1.wait_time_ms DESC

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/06/2012 :  15:00:12  Show Profile  Reply with Quote
Did you mean to use lower case L instead of the digit 1 as the table alias? Change to one of these
--compare the results
SELECT [1].wait_type, 
([1].wait_time_ms - O.wait_time_s) accum_wait_ms --red squigly line under wait_time_ms on this line
FROM #OriginalWaitSnapshot O
INNER JOIN #LatestWaitStatSnapshot [1] ON
O.wait_type = [1].wait_type
WHERE [1].wait_type_ms > O.wait_time_ms
ORDER BY [1].wait_time_ms DESC


Or,
--compare the results
SELECT x.wait_type,
       (x.wait_time_ms - O.wait_time_s)     accum_wait_ms --red squigly line under wait_time_ms on this line
FROM   #OriginalWaitSnapshot O
       INNER JOIN #LatestWaitStatSnapshot x
            ON  O.wait_type = x.wait_type
WHERE  x.wait_type_ms > O.wait_time_ms
ORDER BY
       x.wait_time_ms                       DESC
Go to Top of Page

viperbyte
Posting Yak Master

USA
132 Posts

Posted - 12/06/2012 :  15:09:34  Show Profile  Reply with Quote
Brackets or letter 'X' worked. Thank you sooo much.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000