Tuesday, July 9, 2013

[SQL Server] Need max date from duplicare records.

[SQL Server] Need max date from duplicare records.


Need max date from duplicare records.

Posted: 09 Jul 2013 02:07 AM PDT

Hello,I have one table which have 3 columnsdt1 dt2 dt3 dt4 dt53/31/2011 3/30/2011 4/4/2011 3/30/2011 4/4/201110/24/2012 10/23/2012 10/27/2012 10/23/2012 10/27/201212/10/2012 12/8/2012 12/19/2012 12/8/2012 12/19/201212/20/2012 12/8/2012 12/19/2012 12/8/2012 12/19/20121/16/2013 1/14/2013 1/24/2013 1/14/2013 1/24/2013when there comes duplicate record in dt2,dt3,dt4,dt5 then i just need max dt from dt1else nullso can you please help me??

SQL Server Agent won't start - The system cannot find the file specified

Posted: 08 Jul 2013 11:50 PM PDT

Hi,For a while now we have been running SQL for our ERP system.Recently i have noticed that a rebuild indexes task has not been running on the SQL database.On closer inspection, i noticed that the SQL server agent is not running - when i try and start the service it tells me 'windows could not start the service - error 2: the system cannot find the file specified.I have taken a look at some posts already which refer the checking the location of the sqlagent.out log file path in the registry.This would all appear ok - but when i try to start the service this file is not updating....I have also tried renaming the file to see if a new file is create but nothing happens....Any advice or pointers that could be given would be greatly appreciated.Cheers Alan

Variable as a location

Posted: 09 Jul 2013 03:41 AM PDT

I was wondering if its possible to have a variable hold the location of a database and table so instead of writing[code="sql"]Select * from database1.dbo.table1[/code]i want to write it like[code="sql"]Declare @Location varchar(30)set @location = 'database1.dbo.table1'Select * from @Location[/code]The end result is to use this in a stored proc that accesses two different databases on the same server

Query Reporting Services subscription start time?

Posted: 09 Jul 2013 05:13 AM PDT

Hi All - I'm trying to gather information regarding the schedules for my subscriptions. Some of the data I need is stored in XML in the database. Below, I'm simply trying to retrieve the value in StartDateTime in the MatchData column from Subscriptions. However, the results return NULL for that column (even though it appears there is data present. I'm sure something is wrong with my query, so I thought I would check. ) Since I've never queried XML before I quite certain I'm not using XMLNAMESPACES right. But, here is what I tried...This should run against any stock installation of SSRS. Just change the name space to reflect your environment:[code="sql"];WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/[removed]/[removed]/[removed]/[removed]' AS ns)SELECT s.EventType ,CAST(s.[MatchData] AS XML).value('(/ns:ScheduleDefinition/ns:StartDateTime)[1]', 'date') AS SubStrtFROM Subscriptions s[/code]Any help is appreciated!

No comments:

Post a Comment

Search This Blog