Parsing error in Microsoft SQL Server Management studio 2008 R2 - sql-server-2008-r2

Here is the CTE query which I am trying to execute:
Parsing error in in CTE query SQL server
The query works fine as you could see in the Live Demo but this IDE is giving me a tough time by giving me the parsing error around the "with" keyword used in the CTE query..

The issue was with the SQL server compact edition..
When I used to create a local db in the IDE with SQL server compact edition, it didn't support the CTE but when I connected to our actual database and then ran the CTE query, it worked.
Even its given in the below link that the compact version does not support CTE:
https://msdn.microsoft.com/en-us/library/bb896140(SQL.100).aspx

Related

Is there a query to get the current DB2 IBM Server restart time/uptime?

I’m used to working with MS SQL and I’m looking for the DB2 equivalent to:
SELECT sqlserver_start_time
FROM sys.dm_os_sys_info
I’m expecting to run something like
SELECT CURRENT SERVER START TIME
FROM SYSIBM.SYSDUMMY1
And get a result back like:
CURRENTSERVERSTARTTIME
07-25-2021 23:59:59.000
Can it be done, and does it make sense in an IBM DB2 environment?

Setting up environment for SQL queries

I know the basic syntax of queries but otherwise I'm a beginner with SQL.
I have an SQL file (.sql) and I downloaded a couple programs (pgadmin and sql workbench).
I have no idea how to get from where I am now to actually writing queries and finding information. How do I set up so I can actually import my SQL file and start writing queries?
pgAdmin is the default GUI for PostgreSQL.
SQL Workbench is a free, DBMS-independent, cross-platform SQL query tool.
Either way, you need to connect to a database to actually run queries. The DBMS can either run on your local machine or you can connect to a remote server - where you need access privileges of course.

Unable to update records - SQL Server 2008 R2 Server/Express and MS Sync Framework 2.1

I am using MS Sync Framework 2.1 and syncing multiple SQL Express 2008 R2 express clients with SQL Express 2008 R2 server. It has been working fine for many months until recently. One of the table with 3000 records is not getting synced any more. I populated the table with Bulk Insert. I cannot even update those records through query analyser using SQL Management Studio.
When I run the T-Sql Update query as
Update myTable set modifiedDate ='sa'
It returns the following message.
(0) records updated
(3000) records updated
The first message is for myTable and second is for myTable_Tracking. So the records are not getting updated in myTable but they are in myTable_Tracking. But when I do Select query I am getting 3000 rows returned.
The same result is found on both Server and Express.
I checked size of transaction log. The Space Used is 94% on SQL Server 2008 R2 Server but on SQL Express Space Used is 17% only.
Any idea people?
Please let me know if you need more information.
I recomend that you take a look on this link:
https://jtabadero.wordpress.com/2012/08/23/things-you-need-to-know-about-sql-data-sync-service/

Error on Deployment of SQL server 2008 R2 reports to SQL Server 2008, Aggregate functions cannot be nested inside other aggregate functions

I have used SQL Server 2008 R2 for developing my reports, and when I tried to deploy it on hosting server which is SQL server 2008 it displayed an error while deploying a report,
Error
The Value expression for the textrun
'Textbox36.Paragraphs[0].TextRuns[0]' contains an aggregate function
(or RunningValue or RowNumber functions) in the argument to another
aggregate function (or RunningValue). Aggregate functions cannot be
nested inside other aggregate functions.
I think following expression is throwing error while deploying from sql server 2008R2 to sql server 2008
Expression
=Sum(IIF(Fields!RegisteredOn.Value >Parameters!FromDate.Value and Fields!RegisteredOn.Value < Parameters!EndDate.Value , 1,0))
Is there any workaround for this in SQL server 2008
You could try replacing the IIF with CASE. I am not sure that IIF is available in all versions of SQL Server.
http://msdn.microsoft.com/en-us/library/ms181765.aspx
--See C. Using CASE to replace the IIf function that is used in Microsoft Access --

Query compatibility SQL server 2008/2000

I am developing some stored procedures in SQL Server 2008.
Some of our customers are running SQL Server 2000.
Is there a way to check whether my queries are compatible without having to install SQL Server 2000? Maybe a transact sql tester?
Regards,
Michel
You could set the compatibility mode to 80 but it's not guaranteed
I would also suggest installing MSDE at least to validate your code and performance.$
Or simply install full SQL Server 2000 to develop with.