How to determine SQL server version number for Compact edition 4 up to full sql server 2008? - sql

Lot's of people have asked and been responded to about how to determine the version of the sql server using things like ##VERSION, or SERVERPROPERTY('productversion') but none of these work with sql server compact edition 4.
Is there some universally supported method to determine which sql server edition and version is in use through a sql query or ado.net code that works for compact edition all the way to full sql server?
I want to determine which exact edition / version of SQL server is in use so I know what type of paging query to issue from my code. Sql CE 4 uses a new format for paging queries same as sql server 2011 (denali) and 2005 and 2008 have their own method that is unsupported in CE 4.
I think the answer is that it's impossible but I just want to be sure I didn't overlook something.

I don't really work with SQL Server anymore but here is my attempt at this little problem.
For version 4 of compact edition the following should give you the version and build.
var ver = new System.Data.SqlServerCe.SqlCeConnection().ServerVersion;
And the following should give you the assembly version
var version = typeof(System.Data.SqlServerCe.SqlCeConnection).Assembly.GetName().Version;

Take a look at this blog post. It has a link to download a utility that detects which version of SQL Compact edition you're running. It also has a link to the source code for the utility which may be of interest to you.

You can use PowerShell , in versions of Windows 7 or newer , it comes pre- installed by default. Use the following command lines :
[System.Reflection.Assembly]::LoadFrom("SQLCeAssembly.dll").GetName().Version
Outputs this:
Major Minor Build Revision
----- ----- ----- --------
4 0 0 0

run this
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
See details here

Related

Export from select Statement to JSON in SQL

I use Microsoft SQL Server Management Studio v17.2. I know that for exporting data to JSON must use method like this:
SELECT *
FROM table1
WHERE [conditions]
FOR JSON PATH, ROOT('root')
but when I use this code in SQL Server Management Studio, an error occurred:
Incorrect syntax near 'json'.
Please help me solve this error.
This doesn't have anything to do with Management Studio; the version of SSMS you're using is irrelevant. It has to do with the version of SQL Server you're running the code against, which is completely separate from the version of SSMS.
FOR JSON was introduced in SQL Server 2016. If you are not running 2016 or better (or Azure SQL Database), you'll need to upgrade, or use a different approach to get your data into JSON format.

SHA2_256 Hashbytes generating different value on SQL Server 2012 with different version

I am facing a weird problem, I have one source - SQL Server 2012 with version no. 10.5.1753.0 - where hashbyte SHA2_256 is generating a null value.
On the other hand, I have another source - SQL Server 2012 with version no. 11.0.3000.0 - where hashbyte SHA2_256 is generating some value.
I have to deal with this problem, where I can't put request to source owner to upgrade their version and still I need to pull records from this source.
Versionnumber 10.5.1753.0 belongs to SQL Server 2008 R2 and not 2012.
SHA256 is only supported in SQL Server 2012+.
(BTW 10.5.1753.0 is a pretty old version back from 2010 and 11.0.3000.0 is from 2012. They really should be updated.)

Transfer database from SQL Server 2008 version 10.50.2500 to 10.0 2531

I cannot believe this is so difficult. Backup / Restore fails. Import and Export both fail with a variety of silly errors.
Is there a way to do this that works?
Try scripting out the schema and data, with the SQL Server Management Studio
Article explaining how to use SQL Server Management Studio
If that doesn't work, you'll have to use a more advanced third party tool. Like, for instance, Red Gate's Sql Toolbelt, where:
SQL Compare allows you to compare and merge schema between 2 databases
Data Compare allows you to compare and merge data between 2 databases

MS SQL Server 2008 "linked server" to Oracle : schema not showing

I have a Windows 2008 Server (x64) running Microsoft SQL 2008 (x64) and I'm creating a Linked Server connection to an Oracle server. I'm able to make the connection, but I cannot see any information regarding which schema a table belongs to.
In SQL 2005, my linked servers show the schema information as I would expect.
Does anyone know how to resolve this issue? Is it an issue with the provider, OraOLEDB.Oracle?
Any help or pointers would be appreciated.
#Boojiboy - When you are looking at the tables via a linked server, there used to be a column for what schema. It appears that in the latest the new Oracle OLEDB drivers don't show this information any longer.
It looks like sp_tables_ex will do the trick, it came from the below article.
--verify tables OK exec sp_tables_ex #table_server = 'LINKED_ORA',
#table_schema='MySchema'
#table_schema is optional. If not
provided, you will get a list of all
tables in all schemas.
http://it.toolbox.com/blogs/daniel-at-work/linking-sql-server-2005-to-oracle-26791
Also in the SQL 08 > Server Objects > Providers
make sure your OraOLEDB.Oracle provider is allowing inprocessing

Firebird's SQL's Substring function not working

I created a view on a machine using the substring function from Firebird, and it worked. When I copied the database to a different machine, the view was broken. This is the way I used it:
SELECT SUBSTRING(field FROM 5 FOR 15) FROM table;
And this is the output on the machine that does not accept the function:
token unknown: FROM
Both computers have this configuration:
IB Expert version 2.5.0.42 to run the queries and deal with the database.
Firebird version 1.5 as server to database.
BDE Administration version 5.01 installed, with Interbase 4.0 drivers.
Any ideas about why it's behaving differently on these machines?
Make sure Firebird engine is 1.5 and there's no InterBase server running on this same box on the port you expected Firebird 1.5.
Make sure you don't have any UDF called 'substring' registered inside this DB so that Firebird is expecting different parameters.
Different engine versions?
Have you tried naming that expression in the result?
SELECT SUBSTRING(field FROM 5 FOR 15) AS x FROM table;