SQL Server FORMAT() not working with 'iv' as culture [duplicate] - c#

I am using SQL Server 2017 and try to use culture in the Format function. When running this Query on the server the result is incorrect:
SELECT ##VERSION --> Microsoft SQL Server 2017 (RTM-CU17) (KB4515579) - 14.0.3238.1 (X64) Sep 13 2019 15:49:57 Copyright (C) 2017 Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64
SELECT FORMAT(SYSDATETIME(), N'Y', 'fa'); --> February 2020
But when running this in another server with SQL server 2017 the script works fine:
SELECT ##VERSION --> Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64) Dec 22 2017 16:13:22 Copyright (C) 2017 Microsoft Corporation Enterprise Edition (64-bit) on Windows 10 Enterprise 10.0 <X64> (Build 16299: )
SELECT FORMAT(SYSDATETIME(), N'Y', 'fa'); --> بهمن, 1398
What has configuration must be checked?
P.S: I realized that this problem occurres on Windows Server 2012 R2 and lower versions.

Finally, I found the problem. This feature depends on the version of Windows which SQL server installed on it. Persian calendar was added in Windows Server 2012 R2 And Windows 10.
This image shows the date format for fa culture in Windows Server 2012 R2 and Windows 10
And this image shows the date format for fa culture in the older version of Windows

In fact, the problem is at Windows Server where the SQLServer is installed.
For any language you want to use, Windows Server must have this language installed at OS level.
To install in "Windows Server 2012 R2" or later, just follow these steps:
Search for "Control Panel" and open it
Select "View by: Large Icons"
Click on "Languages"
Add the Language you need, and after that also install the "Language Pack" for the new language added.
After this, your parameter in FORMAT function will be accepted.

Related

Microsoft SQL Server compatibility issue (C# Application)

I am developing a C# application on Windows 10, under Visual Studio 2015.
I can see that I have installed on that PC Microsoft SQL Server 2005 Compact Edition, 2012 Native Client, 2014 Express LocalDB, 2016 Local DB and other stuff like this.
I did not voluntarily installed any of this, they must have been with MVS 2015 or with the Windows.
The app that I made throws an exception on a Windows 7 PC with Microsoft SQL Server Compact 4.0 SP1 and all the Microsoft SQL Server 2014 specific stuff (including Express LocalDB).
If I run sqllocaldb i command on Win10 PC I have only mssqllocaldb connection with 13.0.1601.5 version number.
On Win7 PC I have the same status except that the version is 12.0.2000.8.
When I run my application I get
This server supports version 782 and earlier, your version is 852.
What can I do so that I can run the app in both computers since I have SQL Server 2014 on both of them fully installed?

Installing MSSQL for Windows 7 and running application made with MSSQL2016 for X86 systems

I'm developing an ERP via Windows Form Application using (C# and SQL) through Visual Studio 2017 and MSSQL SERVER 2016 (VERSION 852) on a 64 bit Machine with Windows 8.
On deploying the application on the X64 machine with SQLLOCALDB (VERSION 852 or above) installed, the application is working fine.
But, I want to distribute the application in my circles having old machines with X86 (32 bit) architecture. The application is getting installed, but on launching the application, the form with DATABASE CONNECTIVITY is creating a problem.
"The database 'MyFirstWFAAPP' cannot be opened because it is version
852. This server supports version 851 and earlier. A downgrade path is not supported. Could not open new database 'MyFirstWFAAPP'. CREATE
DATABASE is aborted. Cannot attach the file
'C:\devx\2018\MyFirstWFAAPP\App_Data\MyFirstWFAAPP.mdf' as database
'MyFirstWFAAPP'. "
PS: Installation of MSSQL SERVER (Local DB) to 32 bit machines, WINDOW 7, has been deprecated by Microsoft (As I've been informed) So, MSSQL SERVER 2016 and above cannot be installed onto Window 7 systems.
Window 7, XP Support SQL SERVER installation either or below SQL SERVER 2008 R2 (VERSION 660/661).
I'm in a dilemma, as I'm have no idea of what to do.
1) Is there any way, we can convert Code of SQL SERVER 2016 to SQL SERVER 2008 (R2) or below??
2) or, should I delete the MSSQL Server 2016 and then install the 2008 editions.
3) or, should I install SQL 2008 on the parallel with SQL SERVER 2016 running. and, also install MSSQL Server Management Studio and choose the targeted versions of MSSQL. (I'm not sure, whether it's possible. Just guessing).
Please support. As, I'm worried.
Thanks and Regards!
Narayan
This has nothing to do with the target platform (x86 vs. x64). This is simply an issue of targeted SQL Server version. SQL Server knows how to upgrade a database file, but there is absolutely no way it can downgrade one. You are distributing a SQL Server 2016 database file (internal version 852), this will only be opened by the SQL Server 2016 or SQL Server 2017.
But the real problem is different. The real problem is that you are distributing the database as an artifact. This is an absolute NO. Just think how will you distribute the next version of your app, your MDF will replace the actual data that was updated by your 'circles'. You must change your application to distribute only scripts for creating and upgrating database. Your framework of choice may well already provide a solution.

How can I programmatically determine if the installed SQL Server is 32 or 64 bit

I'm trying to programmatically determine if an installed instance of SQL Server (2005-2012) is 32 or 64 bit in C#. I've looked through the registry and have not found anything and I don't want to base it off whether it is installed in Program Files (x86) since they may have installed it elsewhere. Is there any where else I can look?
Edit: I won't know if I'm able to connect to the instance, so running a query won't always be possible.
Thanks
You can use the file properties for the instance you want to look at.
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\sqlservr.exe
The file description will indicate if it's 64 bit.
"SQL Server Windows NT - 64 bit"
Open a SQL Command to the instance and run the below. If you are looking for a file based approach. It is a little different.
SELECT ##VERSION
This will tell you what you need to know. An example output would be
Microsoft SQL Server 2008 R2 (SP3) - 10.50.6220.0 (X64) Mar 19 2015
12:32:14 Copyright (c) Microsoft Corporation Enterprise Edition
(64-bit) on Windows NT 6.1 (Build 7600: ) (Hypervisor)

Microsoft.ReportViewer : How to upgrade Version from 8 to 11

I have developed an c# desktop app on Visual Studio 2013 and Microsoft Sql server 2012. When i deploy this app on my client system which has sql server 2008, app is running correctly but reports are not working. It throws exception:
Could find the file or assembly Microsoft.ReportViewer.Common V 11.0.0.0
When i see the assembly it has V 8.0.0.0. My question is how to upgrade this to V 11 without installing Sql server 2012 ? Is there any way to copy the new version files in assembly ?
Yes, it is possible. There is a runtime available for the report viewer.
You need to download and install the following two files:
Microsoft System CLR Types for Microsoft SQL Server 2012 (x86, x64)
Microsoft Report Viewer 2012 Runtime
(Don't mind that the first file has "SQL Server 2012" in its name. It's just a tiny library with a scary name required by the Report Viewer Runtime. It won't actually install SQL Server 2012. More details can be found in the "System Requirements" section of the Report Viewer Runtime link.)

What is sql version 662?

This server support version 662 and ealier. A downgrade path is not supported..
I have vs studio 2010 express + sql 2008 R2 express
This error message is a bit misleading. SQL Server 2008 supports
database version 655 and earlier. But with support for 15000
partitions in SQL Server 2008 SP2, databases enabled for 15000
partitions are upgraded to version 662.
Tell me if this helps: http://rusanu.com/2010/11/23/this-server-supports-version-662-and-earlier/

Categories