Create a sql server snapshot using powershell - powershell

I was attempting to use the code from here However PS says Exception calling "Create" with "0" argument(s): "Create failed for Database 'NewSnapshot'. "
What arguments is the script missing? Is there a better way of accomplishing a snapshot than what the script from the link provides?
I'm using the following version:
Microsoft SQL Server 2012 (SP1) - 11.0.3153.0 (X64)
Jul 22 2014 15:26:36
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.2 (Build 9200: )

Related

DBVisualizer displays null on date field holding '0001-01-01'

I issued an SQL statement in DbVis:
select vestdate, name from person where vestdate is not null
And got many results where DbVisualizer showed vestdate as (null)!
After investigating, I discovered that the vestdate was '0001-01-01', so the query correctly returned these records, but DbVisualizer displays them as (null).
I have just switched from windows 8 to windows 10.
It works on windows 8 (displays '0001-01-01'), but not not windows 10 (displays null):
Product: DbVisualizer Pro 11.0.4 [Build #3103]
OS: Windows 8.1
OS Version: 6.3
OS Arch: amd64
Java Version: 1.8.0_252
Java VM: OpenJDK 64-Bit Server VM
Java Vendor: AdoptOpenJDK
Java Home: c:\program files\dbvisualizer\jre
DbVis Home: C:\Program Files\DbVisualizer
User Home: -------
PrefsDir: -------
SessionId: 55
BindDir: -------
Product: DbVisualizer Pro 11.0.5 [Build #3113]
OS: Windows 10
OS Version: 10.0
OS Arch: amd64
Java Version: 1.8.0_252
Java VM: OpenJDK 64-Bit Server VM
Java Vendor: AdoptOpenJDK
Java Home: c:\program files\dbvisualizer\jre
DbVis Home: C:\Program Files\DbVisualizer
User Home: -------
PrefsDir: -------
SessionId: 968
BindDir: -------
Any ideas how to make the program show me the real value, not the interpreted value of null?
The issue is explained in an IBM support document:
Problem
Trying to insert a date value into a date column before 1940 or after 2039 will represent the date as NULL within the respective database table.
Cause
This is caused by a limitation with the IBM i database Toolbox JDBC driver as detailed in the related link:
How does the Toolbox JDBC driver deal with dates before 1940 (or after 2039)?
The IBM i database supports several date formats. The Toolbox JDBC driver uses the date format that is set up as the default on the IBM i system. This default is usually set to "mdy" which only supports dates between 1940 and 2039. You can override the date format by specifying the "date format" property when opening the JDBC connection. The best choice is "iso", which supports a full four-digit date. The easiest way to do this is to add ";date format=iso" to the end of the URL used when connecting to the database.
Resolving The Problem
Appending the ";date format=iso" to the host connection property for the applicable database
via Preferences-> EGL-> SQL Database Connections will then show the respective dates correctly eg:
1939-01-01.
The issue can be fixed in DBVisualizer by doing the following:
Database -> Edit Database Connection(s)...
Select Properties tab
Select Driver Properties
Edit parameters date format and time format to be iso
Apply Changes
Disconnect and reconnect

Why is my Hive QL Query that I run in SSMS via Openquery through the Hortonworks ODBC Driver producing an error?

I set up a connection to a Hive server using the Hortonworks ODBC Driver for Apache Hive. Version info is below:
OS: Windows Server 2012 R2 Standard
Hive: 1.2.1000.2.6.5.4-1
Hadoop: 2.7.3.2.6.5.4-1
Hortonworks ODBC Driver for Apache Hive
ODBC Version: 03.80
Driver Version: 2.1.12.1017
Bitness: 64-bit
Locale: en_US
I can run the queries below using the connector that I configured in Teradata SQL Assistant with no issues. I set up my DSN as a linked server in SSMS. However, when I attempt to run the queries in SSMS using openquery, I have some issues. Info on my SQL Server is below:
Microsoft SQL Server 2016 (SP2-CU3) (KB4458871) - 13.0.5216.0 (X64) Sep 13 2018 22:16:01 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: ) (Hypervisor)
Here is some info on the table that I am querying:
Table Name: instrumentapps_event
Using OPENQUERY, I am capable of querying the Hive DB through SSMS with the following query:
SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event')
The above query returns the contents of the desired table. However, the query below produces an error:
SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event WHERE to_date(from_unixtime(UNIX_TIMESTAMP(load_ts,''yyyy/MM/dd''))) >= to_date(''2019-03-01'')')
The error is as follows:
Msg 7355, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "KMhivehttp" supplied inconsistent metadata for a column. The name was changed at execution time.
How can I fix this?
While I'm unsure how to fix the problem that I previously faced (I suspect it to be a bug with the Hortonworks ODBC driver), I did discover a workaround.
Instead of running:
SELECT * FROM OPENQUERY(KMhivehttp,
'SELECT *
FROM dmfwk_gold.instrumentapps_event
WHERE to_date(from_unixtime(UNIX_TIMESTAMP(load_ts,''yyyy/MM/dd''))) >=
to_date(''2019-03-01'')
')
I now use:
SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event')
WHERE load_ts >= CAST('2019-03-01' AS DATE);
This allows me to avoid any metadata errors.

How to know username and password of Oracle 10g Ex? [duplicate]

This question already has answers here:
Forgot Oracle username and password, how to retrieve?
(5 answers)
Closed 6 years ago.
Actually, I forgot my username and password of Oracle 10g Ex. Are there any way to find them?
Log into the database server as a user belonging to ‘dba’ [unix ] or ‘ora_dba’ [windows ] group , typically ‘oracle’, or an administrator on your windows machine. Then you will be able to log in to Oracle as SYS user, and change the SYSTEM password by doing the following
$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.1.0 - Production on Mon Apr 5 15:32:09 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> show user
USER is "SYS"
SQL> passw system
Changing password for system
New password:
Retype new password:
Password changed
SQL> quit
Next, we need to change the password of SYS:
$ sqlplus "/ as system"
SQL*Plus: Release 9.2.0.1.0 - Production on Mon Apr 5 15:36:45 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon> ::= <username>[/<password>][#<connect_string>] | /
Enter user-name: system
Enter password:
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> passw sys
Changing password for sys
New password:
Retype new password:
Password changed
SQL> quit
You should now be able to log on the SYS and SYSTEM users, with the passwords you just typed in.

SQL server 2008 R2 Arithmetic overflow error converting numeric to data type numeric

I have a confusing error that I can not understand on SQL Server 2008 R2.
But when I try the same request on a local server (SQL Server 2008 R2 also) everything works fine.
So here is the request raising the problem:
select cast(cast(1.260 as numeric(13,3)) as numeric(10,2))
I also added the result of some queries indicating the environment of each server:
On the local server:
---------------------------------------
1.26
(1 row(s) affected)
Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64)
Apr 22 2011 19:23:43
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
ARITHABORT
---------------------------------------------------------------------------------------------
1
(1 row(s) affected)
ARITHIGNORE
---------------------------------------------------------------------------------------------
NULL
(1 row(s) affected)
ANSI_WARNINGS
---------------------------------------------------------------------------------------------
1
(1 row(s) affected)
On the remote server:
Msg 8115, Level 16, State 7, Line 1
Arithmetic overflow error converting numeric to data type numeric.
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)
Jun 17 2011 00:54:03
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2) (Hypervisor)
(1 row(s) affected)
ARITHABORT
------------------------------------------------------------------------------------------------------------
1
(1 row(s) affected)
ARITHIGNORE
------------------------------------------------------------------------------------------------------------
NULL
(1 row(s) affected)
ANSI_WARNINGS
------------------------------------------------------------------------------------------------------------
1
(1 row(s) affected)
My question is how can I reproduce the problem that is occuring on the remote server. As you can see, the parameters ARITH... and ANSI_.. are the same on both servers. Is there any configuration on that kind of errors on the SQL Server?
The NUMERIC_ROUNDABORT option is ON
When SET NUMERIC_ROUNDABORT is ON, an error is generated after a loss of precision occurs in an expression. When OFF, losses of precision do not generate error messages and the result is rounded to the precision of the column or variable storing the result.
Normally this is OFF because when ON indexed views etc can fail.
I've never changed this, ever.
SET NOCOUNT ON;
GO
PRINT 'ON'
set NUMERIC_ROUNDABORT ON;
select cast(cast(1.260 as numeric(13,3)) as numeric(10,2));
GO
PRINT 'OFF'
set NUMERIC_ROUNDABORT OFF;
select cast(cast(1.260 as numeric(13,3)) as numeric(10,2));
GO
gives
ON
---------------------------------------
Msg 8115, Level 16, State 7, Line 3
Arithmetic overflow error converting numeric to data type numeric.
OFF
---------------------------------------
1.26

What is the most up to date production version of mysqli ?

Tough to figure out if I have an up to date version of mysqli or not.
I use this in a web page :
$link = mysqli_connect($hostname, $username, $password, $dbname);
printf("MYSQLi Client library version: %s<br>\n", mysqli_get_client_info());
The output is :
MYSQLi Client library version: mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $
Well that is all well and nice .. but my MySQL rev is 5.5.30 base on this :
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to ";
// print the MySQL server version
printf("MySQL server version: %s<br>\n", mysql_get_server_info());
Which results in :
Connected to MySQL server version: 5.5.30
Should I expect to see a mysqli rev of 5.5.x or am I wrong?
Any insight would be helpful.
This is Apache 2.4.4 and PHP 5.4.12 if that helps :
$ /usr/local/bin/php --version
PHP 5.4.12 (cli) (built: Feb 25 2013 19:25:44)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
$ /usr/local/bin/httpd -v
Server version: Apache/2.4.4 (Unix)
Server built: Feb 28 2013 10:46:58
The mysqli extension has been built using a MySQL distribution which version was different from your (MySQL) server version:
http://php.net/manual/en/mysqli.installation.php
You'll notice the output refers to MYSQLi Client library version.
To obtain the version of your server distribution, you can execute the following query using the same PHP version of PHP and mysqli extension:
SELECT ##version;
$mysqli = new mysqli('host', 'username', 'my_secret_password...');
$result = $mysqli->query('SELECT ##version;');
print_r($result->fetch_array());