The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions

You do not need to use ORDER BY in inner query after WHERE clause because you have already used it in ROW_NUMBER() OVER (ORDER BY VRDATE DESC). SELECT * FROM ( SELECT Stockmain.VRNOA, item.description as item_description, party.name as party_name, stockmain.vrdate, stockdetail.qty, stockdetail.rate, stockdetail.amount, ROW_NUMBER() OVER (ORDER BY VRDATE DESC) AS RowNum –< ORDER BY FROM … Read more

Is it possible to use user defined aggregates (clr) with window functions (over)?

You’re right that it’s tricky to find anything in the documentation. But searching the Connect website, I managed to find this gem: Today, you can use CLR aggregates with OVER clause and PARTITION BY just like regular aggregate functions. Once we have support for window functions… Which was a response from Microsoft. However, searching on … Read more

Use TO_DATE in SQL Server 2012

SQL-Server has no TO_DATE function. You have to use convert. See here — Specify a datetime string and its exact format SELECT TO_DATE(‘2012-06-05’, ‘YYYY-MM-DD’) FROM dual; — Specify a datetime string and style 102 (ANSI format), raises an error if conversion fails SELECT CONVERT(DATETIME, ‘2012-06-05’, 102); — TRY_CONVERT available since SQL Server 2012 (returns NULL … Read more

SSIS Package Not Running as 32bit in SQL Server 2012

By default, everything will run in 64 bit on the servers. To change this behaviour, you need to indicate that the 32bit version of dtexec should be used. For the 2012 SSISDB, we have two easy ways of invoking our packages: SQL Agent and the catalog.start_execution method. catalog.start_execution For single serving package runs, you can … Read more