How do I verify SQL Server versions, Including version, service pack, cumulative update and patch - sql

I have 250 VM's for different clients using different version of SQL server installed.
I ran the below command to get the details but the information was not successful
SELECT
SERVERPROPERTY('productversion'),
SERVERPROPERTY('productlevel'),
SERVERPROPERTY ('edition'),
##version,
SERVERPROPERTY('PatchLevel')
Can someone please help? I need the information for details like SQL Server version, service pack, cumulative update and patches installed to the server.

Hope you need this.,
select ##VERSION
Hope this helps you.,
SELECT SERVERPROPERTY('MachineName') AS [MachineName],
SERVERPROPERTY('ServerName') AS [ServerName],
SERVERPROPERTY('InstanceName') AS [Instance],
SERVERPROPERTY('IsClustered') AS [IsClustered],
SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS],
SERVERPROPERTY('Edition') AS [Edition],
SERVERPROPERTY('ProductLevel') AS [ProductLevel], -- What servicing branch (RTM/SP/CU)
SERVERPROPERTY('ProductUpdateLevel') AS [ProductUpdateLevel], -- Within a servicing branch, what CU# is applied
SERVERPROPERTY('ProductVersion') AS [ProductVersion],
SERVERPROPERTY('ProductMajorVersion') AS [ProductMajorVersion],
SERVERPROPERTY('ProductMinorVersion') AS [ProductMinorVersion],
SERVERPROPERTY('ProductBuild') AS [ProductBuild],
SERVERPROPERTY('ProductBuildType') AS [ProductBuildType], -- Is this a GDR or OD hotfix (NULL if on a CU build)
SERVERPROPERTY('ProductUpdateReference') AS [ProductUpdateReference], -- KB article number that is applicable for this build
SERVERPROPERTY('ProcessID') AS [ProcessID],
SERVERPROPERTY('Collation') AS [Collation],
SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled],
SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly],
SERVERPROPERTY('FilestreamConfiguredLevel') AS [FilestreamConfiguredLevel],
SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled],
SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus],
SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath],
SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath],
SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version];

Here is a query that gives you all the Server Properties available through the SERVERPROPERTY system function.
You can run this on old SQL versions and if the Property didn't exist back then, the function will just safely return a NULL.
SELECT
SERVERPROPERTY('BuildClrVersion') AS BuildClrVersion
,SERVERPROPERTY('Collation') AS [Collation]
,SERVERPROPERTY('CollationID') AS CollationID
,SERVERPROPERTY('ComparisonStyle') AS ComparisonStyle
,SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS]
,SERVERPROPERTY('Edition') AS [Edition]
,SERVERPROPERTY('EditionID') AS EditionID
,SERVERPROPERTY('EngineEdition') AS EngineEdition
,SERVERPROPERTY('FilestreamConfiguredLevel') AS FilestreamConfiguredLevel
,SERVERPROPERTY('FilestreamEffectiveLevel') AS FilestreamEffectiveLevel
,SERVERPROPERTY('FilestreamShareName') AS FilestreamShareName
,SERVERPROPERTY('HadrManagerStatus') AS HadrManagerStatus
,SERVERPROPERTY('InstanceDefaultDataPath') AS InstanceDefaultDataPath
,SERVERPROPERTY('InstanceDefaultLogPath') AS InstanceDefaultLogPath
,SERVERPROPERTY('InstanceName') AS [Instance]
,SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS IsAdvancedAnalyticsInstalled
,SERVERPROPERTY('IsClustered') AS [IsClustered]
,SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled]
,SERVERPROPERTY('IsHadrEnabled') AS IsHadrEnabled
,SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly]
,SERVERPROPERTY('IsLocalDB') AS IsLocalDB
,SERVERPROPERTY('IsPolybaseInstalled') AS IsPolybaseInstalled
,SERVERPROPERTY('IsSingleUser') AS IsSingleUser
,SERVERPROPERTY('IsXTPSupported') AS IsXTPSupported
,SERVERPROPERTY('LCID') AS LCID
,SERVERPROPERTY('LicenseType') AS LicenseType
,SERVERPROPERTY('MachineName') AS [MachineName]
,SERVERPROPERTY('ProcessID') AS [ProcessID]
,SERVERPROPERTY('ProductBuild') AS ProductBuild
,SERVERPROPERTY('ProductBuildType') AS ProductBuildType
,SERVERPROPERTY('ProductLevel') AS ProductLevel
,SERVERPROPERTY('ProductMajorVersion') AS ProductMajorVersion
,SERVERPROPERTY('ProductMinorVersion') AS ProductMinorVersion
,SERVERPROPERTY('ProductUpdateLevel') AS ProductUpdateLevel
,SERVERPROPERTY('ProductUpdateReference') AS ProductUpdateReference
,SERVERPROPERTY('ProductVersion') AS [ProductVersion]
,SERVERPROPERTY('ResourceLastUpdateDateTime') AS ResourceLastUpdateDateTime
,SERVERPROPERTY('ResourceVersion') AS ResourceVersion
,SERVERPROPERTY('ServerName') AS [ServerName]
,SERVERPROPERTY('SqlCharSet') AS SqlCharSet
,SERVERPROPERTY('SqlCharSetName') AS SqlCharSetName
,SERVERPROPERTY('SqlSortOrder') AS SqlSortOrder
,SERVERPROPERTY('SqlSortOrderName') AS SqlSortOrderName
,##VERSION AS [Version]

Related

Oracle SQL developer connect issue [duplicate]

I'm accessing an Oracle Database from a java application, when I run my application I get the following error:
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
You may also try to check the version of the Oracle jdbc driver and Oracle database. Just today I had this issue when using ojdbc6.jar (version 11.2.0.3.0) to connect to an Oracle 9.2.0.4.0 server. Replacing it with ojdbc6.jar version 11.1.0.7.0 solved the issue.
I also managed to make ojdbc6.jar version 11.2.0.3.0 connect without error, by adding oracle.jdbc.timezoneAsRegion=false in file oracle/jdbc/defaultConnectionProperties.properties (inside the jar). Found this solution here (broken link)
Then, one can add -Doracle.jdbc.timezoneAsRegion=false to the command line, or AddVMOption -Doracle.jdbc.timezoneAsRegion=false in config files that use this notation.
You can also do this programmatically, e.g. with System.setProperty.
In some cases you can add the environment variable on a per-connection basis if that's allowed (SQL Developer allows this in the "Advanced" connection properties; I verified it to work when connecting to a database that doesn't have the problem and using a database link to a database which has).
In a plain a SQL-Developer installation under Windows go to directory
C:\Program Files\sqldeveloper\sqldeveloper\bin
and add
AddVMOption -Duser.timezone=CET
to file sqldeveloper.conf.
Error I got :
Error from db_connection.java -->> java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
ORA-00604: error occurred at recursive SQL level 1ORA-01882: timezone region not found
Prev code:
public Connection getOracle() throws Exception {
Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:#127.0.0.1:1521:tap", "username", "pw");
return conn;
}
new Code:
public Connection getOracle() throws Exception {
TimeZone timeZone = TimeZone.getTimeZone("Asia/Kolkata");
TimeZone.setDefault(timeZone);
Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:#127.0.0.1:1521:tap", "username", "pw");
return conn;
}
now it is working!!
Update the file oracle/jdbc/defaultConnectionProperties.properties in whatever version of the library (i.e. inside your jar) you are using to contain the line below:
oracle.jdbc.timezoneAsRegion=false
What happens is, that the JDBC client sends the timezone ID to the Server. The server needs to know that zone. You can check with
SELECT DISTINCT tzname FROM V$TIMEZONE_NAMES where tzname like 'Etc%';
I have some db servers which know about 'Etc/UTC' and 'UTC' (tzfile version 18) but others only know 'UTC' (tz version 11).
SELECT FILENAME,VERSION from V$TIMEZONE_FILE;
There is also different behavior on the JDBC client side. Starting with 11.2 the driver will sent the zone IDs if it is "known" to Oracle, whereas before it sent the time offset. The problem with this "sending of known IDs" is, that the client does not check what timezone version/content is present on the server but has its own list.
This is explained in Oracle Support Article [ID 1068063.1].
It seems it also depends on the Client OS, it was more likely that Etc/UTC fails with Ubuntu than RHEL or Windows. I guess this is due to some normalization but I haven't figured out what exactly.
in eclipse go run - > run configuration
in there go to JRE tab in right side panels
in VM Arguments section paste this
-Duser.timezone=GMT
then Apply - > Run
I had this problem when running automated tests from a continuous integration server. I tried adding the VM argument "-Duser.timezone=GMT" to the build parameters, but that didn't solve the problem. However, adding the environment variable "TZ=GMT" did fix it for me.
I ran into this problem with Tomcat. Setting the following in $CATALINA_BASE/bin/setenv.sh solved the issue:
JAVA_OPTS=-Doracle.jdbc.timezoneAsRegion=false
I'm sure that using one of the Java parameter suggestions from the other answers would work in the same way.
ERROR :
ORA-00604: error occurred at recursive SQL level 1 ORA-01882: timezone region not found
Solution:
CIM setup in Centos.
/opt/oracle/product/ATG/ATG11.2/home/bin/dynamoEnv.sh
Add this java arguments:
JAVA_ARGS="${JAVA_ARGS} -Duser.timezone=EDT"
In Netbeans,
Right-click your project -> Properties
Go to Run (under Categories)
Enter -Duser.timezone=UTC or -Duser.timezone=GMT under VM Options.
Click Ok, then re-run your program.
Note: You can as well set to other timestones besides UTC & GMT.
If this problem is in JDeveloper:
Change the project properties for both the model and the view project -> run/debug -> default profile -> edit
add the following run option:
-Duser.timezone=Asia/Calcutta
Make sure that the above time zone value is fetched from your database as follows:
select TZNAME from V$TIMEZONE_NAMES;
Along with that you'd want to check the time zone settings in your jdev.conf as well as in the JDeveloper -> Application Menu -> Default Project Propertes -> Run/Debug -> Default Profile -> Run Options.
I also same faced similar issue.
Environment:
Linux, hibernate project, ojdbc6 driver while querying oracle 11g database.
Resolution
TZ parameter was not set in linux machine, that basically tell oracle about the timezone.
So, After adding export statment "export TZ=UTC" at time of application start solved my problem.
UTC--> Change accorind to your timezone.
I had the same problem when trying to make a connection on OBIEE to Oracle db.
I changed my Windows timezone from (GMT+01:00) West Central Africa to (GMT+01:00) Brussels, Copenhagen, Madrid, Paris. Then I rebooted my computer and it worked just fine.
Seems like Oracle was not able to recognize the west central Africa timezone.
This issue happens as the code which is trying to connect to db, has a timezone which is not in db.
It can also be resolved by setting the time zone as below or any valid time zone available in oracle db.
valid time zone which can be found select * from v$version;
System.setProperty("user.timezone", "America/New_York");
TimeZone.setDefault(null);
I too had the same problem when i tried to create connection in JDeveloper. Our server located in different timezone and hence it raised the below errors as:
ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
I referred many forums which asked to include timezone in the Java Options(Run/Debug/Profile) of Project properties and Default Project properties as -Duser.timezone="+02:00" bBut it didn't work for me. Finally the following solution worked for me.
Add the following line to the JDeveloper's configuration file (jdev.conf).
AddVMOption -Duser.timezone=UTC+02:00
The file is located in "<oracle installation root>\Middleware\jdeveloper\jdev\bin\jdev.conf".
In my case I could get the query working by changing "TZR" with "TZD"..
String query = "select * from table1 to_timestamp_tz(origintime,'dd-mm-yyyy hh24:mi:ss TZD') between ? and ?";
I was able to solve the same issue by setting the timezone in my linux system (Centos6.5).
Reposting from
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html
set timezone in /etc/sysconfig/clock e.g. set to ZONE="America/Los_Angeles"
sudo ln -sf /usr/share/zoneinfo/America/Phoenix /etc/localtime
To figure out the timezone value try to
ls /usr/share/zoneinfo
and look for the file that represents your timezone.
Once you've set these reboot the machine and try again.
Facing the same issue using Eclipse and a distant Oracle Database, changing my system time zone to match the time zone of the database server fixed the problem.
Re-start the machine after changing system time zone.
I hope this can help someone
java.sql.SQLException: ORA-00604: error occurred at recursive SQL
level 1 ORA-01882: timezone region not found
For this type of error, just change your system time to your country's standard GMT format
e.g. Indian time zone is chennai,kolkata.
Happens when you use the wrong version of OJDBC jar.
You need to use
11.2.0.4
For my case, i set the timezone at my OS level (ubuntu) with this command.
timedatectl set-timezone {timezone}
For example,
timedatectl set-timezone Africa/Kampala
This might be a bit late but It may help someone.
I encountered this issue while working on spring-boot application and failed to connect to the Oracle DB.
Error:
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
SELECT DBTIMEZONE FROM dual; -- This return: +00:00
timedatectl #The OS on the other hand returned correct time and timezone
Since I am not a system admin and not allowed to change system config, I had to apply a workaround in the codes.
spring.datasource.hikari.data-source-properties.oracle.jdbc.timezoneAsRegion=false
#Added the above into the application property file
The working solution came from the below link
Working solution URL
Edit
After the DBA patched the oracle with the missing timezone patches, The above (...timezoneAsRegion=false) was no longer needed.
For Spring-Boot Application - // add below two lines
#SpringBootApplication
public class Application {
public static void main(String[] args) {
// add below two lines
System.out.println("Setting the timezone"+TimeZone.getTimeZone("GMT+9:00").getID());
TimeZone.setDefault(TimeZone.getTimeZone("GMT+9:00"));
SpringApplication.run(Application.class, args);
}
}

SQL looking for a part number ending in '~0000'

I am trying to find records ending in ~0000 such as ABC~0000
but everything I try doesn't seem to work. Some examples:
and left (mfr_part_number, 4) = 'ABC~' -- finds nothing
and left (mfr_part_number, 3) = 'ABC' -- finds stuff
AND RIGHT(MFR_PART_NUMBER, 4) = '0000' -- finds nothing
AND RIGHT(MFR_PART_NUMBER, 5) = '~0000' -- finds nothing
and DbFunctions.Like(MFR_PART_NUMBER,'%0000') -- suggested elsewhere, but not recognized in MSSMS.
I am using:
SQL Server Management Studio 15.0.18206.0
Microsoft Analysis Services Client Tools 15.0.1567.0
Microsoft Data Access Components (MDAC) 10.0.18362.1
Microsoft MSXML 3.0 6.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 10.0.18363
Thanks!
Are you using all of those AND statements in your WHERE clause? If so, that would cause nothing to return if there's no data that matches all criteria.
Try
SELECT column1, column2...
FROM yourdb
WHERE MFR_PART_NUMBER LIKE '%0000'

When trying to connect to Microsoft Azure from an external source I get the following error:

When trying to connect to Microsoft Azure from an external application source (SNAPPII) I get the following error:
I am using an XML template as supplied by SNAPPII tech support but they are unable to pinpoint the issue.
Can anyone help pinpoint the issue?
Error during query execution. Try to check the Data Source Configuartion.
Error : ERROR [42000] [Microsoft][SQL Server Native Client 10.0][SQL Server]Reference to database and/or server name in ‘ODBC.dbo.TableName’ is not supported in this version of SQL Server
I have enclosed a code for xml file below.
I believe this type of connection should work with Microsoft Azure databases but to be honest I am a complete newbie in this environment.
<ext_db_settings>
<connection_strings>
<connection_string name="foreland"><![CDATA[Driver={SQL Server Native Client 10.0}; Server=tcp:ianm.database.windows.net; Database=foreland; Uid=ian.marks#ianm; Pwd=xxxxx; Encrypt=yes;]]></connection_string>
</connection_strings>
<query command="select" connection_string_name="foreland" type="sql" cache_timeout="0" max_size="5">
<body><![CDATA[
SELECT *
FROM [ODBC].[dbo].[TableName]
]]></body>
</query>
<query command="add" connection_string_name="foreland" type="sql">
<body><![CDATA[
INSERT INTO [TableName]
(
Id,
Name,
Age,
Residence
)
VALUES
(
'[set.Id]',
'[set.Name]',
'[set.Age]',
'[set.Residence]'
)
]]></body>
</query>

Delphi - Either BOF or EOF is True, or the current record has been deleted

This error showed when I tried to select on an empty table in MS SQL Server 2005: "either BOF or EOF is True, or the current record has been deleted". I have used TADOConnection and TADODataSet in Delphi 5 to connect and retrieve data from the database.
Conn := TADOConnection.Create(nil);
DataSet := TADODataSet.Create(nil);
Conn.ConnectionString := 'Provider=SQLOLEDB.1;Password=sa;' +
'Persist Security Info=True;' +
'User ID=user;Initial Catalog=mydb;' +
'Data Source=MYPC\SQLEXPRESS;' +
'Use Procedure for Prepare=1;' +
'Auto Translate=True;Packet Size=4096;' +
'Workstation ID=MYPC;' +
'Use Encryption for Data=False;' +
'Tag with column collation when possible=False';
Conn.LoginPrompt := False;
Conn.Open;
DataSet.Connection := Conn;
DataSet.CommandText := 'SELECT * FROM MYTABLE';
DataSet.Open;
DataSet.Free;
Conn.Free;
Is there a way to check if a database table is empty without incurring such error?
This error originally occured with an update to MDAC_TYP (to 2.6 from memory). According to an old Borland advisory
"This is a bug in the SQL Server provider. Set
CursorLocation = clUseClient to eliminate the error."
There was a ADOExpress patch available from Borland, but the link doesn't work. Embarcadero now host it here: ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/d5adoupdate2.exe(Thanks for the official link Jeroen!)
I would recommend downloading and installing all patches listed on the Embarcadero site, assuming you can find them.
Download the ADO update for Delphi 5 here: ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/d5adoupdate2.exe
Make sure you also have the regular update installed:
English Enterprise
English Professional
English Standard
There are more updates (Corba, original ADO install) and languages (French, German), but these should get you going.
There also used to be a http://info.borland.com/devsupport/delphi/download_files/zlibupdate.zip, but it is not on the ftpd servers.
--jeroen
It was long time agom but I recall that this problem in Delphi 5 resolves by Delphi update. Early version has serious problems with ADO components
P.S. Also I see that your code uses not typical runtime creation of components and does not use some container like data module or form (not good usually) for visual work with components. Also sometimes useful run simple queries via adoConnection.execute. If you do not use visual components, handling of ADO's Recordset object is much the same as Delphi's AdoDataset.
Since I spent a whole day on this, here is a wrap up of what I did in the end.
Delphi 5 Pro Installation with ADO Express
Uninstall Delphi 5, also deleted installation directory
Install Delphi 5 Pro (I only have a German Delphi Pro edition available)
Install Delphi 5 Pro Update (I used the German update)
Install Delphi 5 ADO Express
Install Delphi 5 ADO Express Update Pack 1
Install Delphi 5 ADO Express Update Pack 2
And the download links (many thanks again Jeroen Wiert Pluimers):
Delphi 5 Pro updates:
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/delphi5/D5ProUpdate.exe
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/delphi5/german/d5proupdate.exe
ADOExpress Update Packs 1 and 2:
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/D5ADOUpgrade.exe
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/d5adoupdate2.exe
And for future reference some screenshots to build the download links (case sensitive):

What does "%%DatabaseEx" do in TSQL?

I was looking at the source of sys.sp_dbcmptlevel in SQL Server 2005.
In the source, there is this line I do not understand how it works.
EXEC %%DatabaseEx(Name = #dbname).SetCompatibility(Level = #input_cmptlevel)
It doesn't appear that DatabaseEx is a stored procedure.
-- does not return any result
select *
from sys.procedures
where [name] like '%DatabaseEx%'
So my questions are
What is DatabaseEx and what does it do?
What is %% before DatabaseEx?
I think the best answer here is that it's not documented, and not supported, so don't rely on it. While it's interesting to know how SQL Server works internally, anything you do with that knowledge has the potential to break in a future hotfix, service pack or release.
Interesting find.
System SP's also refer to %%Object, %%Relation, %%ColumnEx, %%LinkedServer, %%Owner, %%CurrentDatabase(), %%ErrorMessage, %%Module, %%DatabaseRef, %%LocalLogin, %%Alias, %%ServerConfiguration, %%IndexOrStats, %%ScalarType (etc)
My interpretation is that the %%() retrieves some kind of (COM?) object based on filter criteria, followed by a method call.
-- Note: database #dbname may not exist anymore
-- Change compatibility level
-- If invoke gets error, exception will abort this proc.
EXEC %%DatabaseEx(Name = #dbname).SetCompatibility(Level = #input_cmptlevel)
it looks like a way to refer to a variable database as an object and make config changes