Quantcast
Channel: SQL Server Database Engine forum
Viewing all 15264 articles
Browse latest View live

Syntax errors creating external data source and file format

$
0
0

Hey There - I'm attempting to use SQL external tables for the first time and its giving me fits. I have a set of .CSV files in ADLS that I've been used for benchmarking other Azure storage options for refreshing SSAS cubes.

I'm running SQL 2019 RC1 installed on an Azure VM:

  • Microsoft SQL Server 2019 (RC1) - 15.0.1900.25 (X64)   Aug 16 2019 14:20:53   Copyright (C) 2019 Microsoft Corporation  Enterprise Evaluation Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor)

I've installed the Polybase and Java components via SQL setup. I"ve verified that IsPolybaseInstalled=1, and I"ve tried changing "hadoop connectivity" from 0 to 1, 4, and 7.

When I execute this:

  • CREATE EXTERNAL DATA SOURCE AzureDataLakeStorage
    WITH
    (
        LOCATION='wasbs://abidata@agilebistoragedev.dfs.core.windows.net'
        ,CREDENTIAL = AzureStorageCredential
     ,TYPE =  HADOOP 
    )

I get the error:

  • Msg 102, Level 15, State 1, Line 21
    Incorrect syntax near 'HADOOP'.

It only works if I specify "TYPE = BLOB_STORAGE" even though most of the docs say HADOOP is needed for ADLS.

Also, when I execute this command:

  • create external file format ADLS_CSV_FileFormat
    WITH
    (   FORMAT_TYPE = DELIMITEDTEXT
    ,    FORMAT_OPTIONS    (   FIELD_TERMINATOR = '|'
                        ,    STRING_DELIMITER = ''
                        ,    DATE_FORMAT         = 'yyyy-MM-dd HH:mm:ss.fff'
                        ,    USE_TYPE_DEFAULT = FALSE
                        )
    );

I get the error:

  • Incorrect syntax near 'EXTERNAL'.

Any suggestions? 


Got a bug or feature request? Tell me about it at http://connect.microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights.


Transactions/s trending upward causing the CPU to trend upward.

$
0
0

Hi,

I'm investigating the performance issue on one of our SQL Server where the rate of transactions/s has suddenly increased significantly within last one week. This is causing the CPU to trend upward and we are running out of time to handle this situation. So far the CPU has increased from 20-30% (Our Normal Baseline) to above 55% and moving up daily. 

I have been struggling to pinpoint the root cause so far. I have checked for the following:

1. No Index scanning found. 
2. No changes to the server or databases. 
3. Two databases showing higher CPU/Wait time with one of them I suspect is causing this issue. 



I would appreciate if someone can guide me to the right directions.

access network share via openrowset

$
0
0

I am trying to access a blob on a network share but keep getting 

Msg 4861, Level 16, State 1, Line 3
Cannot bulk load because the file "\\server\share\1.jpg" could not be opened. Operating system error code 5(failed to retrieve text for this error. Reason: 15105).

the command is: 

select * from openrowset ( 
           bulk '\\server\share\1.jpg' 
           ,SINGLE_BLOB) x 

I can access the file from windows. I have given permissions to the share for the domain user running sqlserver 

obviously a delegation error. can a username/password be specified in the sp or openrowset? I just want access through sqlserver. I dont care how. would an assembly bypass this ? 

thanx


???

what would be affected if I change database master key password? will the application affected?

$
0
0
 

https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-master-key-transact-sql?view=sql-server-ver15

USE AdventureWorks2012;
ALTER MASTER KEY REGENERATE WITH ENCRYPTION BY PASSWORD = 'dsjdkflJ435907NnmM#sX003';
GO

Wondering if it is safe to   just generate a new key when the old key's password is unknown(deployed by citrix install) https://discussions.citrix.com/topic/399205-wem-and-alwayson-group/

I can use backup and restore to add the database to AG group, but cannot use seeding if the password is unknown. it would be nice to just regenerate or add a new password https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-master-key-transact-sql?view=sql-server-ver15

PowerShell add SQL service account to Batch Logon on remote computers, dbatools

$
0
0

      This is a good tool, https://www.powershellgallery.com/packages/dbatools/0.9.59/Content/functions%5CSet-DbaPrivilege.ps1 

.EXAMPLE 
       'sql1','sql2','sql3' | Set-DbaPrivilege -Type IFI 

if I run remotely, it doesn't work, no error msg or any msg. but it works if run locally on the sql server itself.  

firewall for domain turned off. user running the powershell is in the local admins of remote sql servers.

SQL Server 2017 Policies Location?

$
0
0

Good afternoon,

   I was wondering if anyone could tell me where the location of the best practices policies is.  These policies are supposed to come as a part of the installation process however, I cannot seem to locate them.  We used Policy-Based Management extensively in my last company and I'd like to implement here as well.  I was able to find them on SQL Server 2016 environment, but every version since the initial release has increased the number of policies and I wanted to ensure I wasn't missing any.  Any help would be greatly appreciated.


Sql Server - Polybase

$
0
0

Hi ,

I am using SQL Server 2019 .I created a blank DB(not datawarehouse) in my local instance.I have a csv file in Azure Storage container and using external data source I want to read the data from csv .I used below queries to create credential,Datasource etc.

CREATE MASTER KEY ENCRYPTION BY PASSWORD = <pwd>; 
CREATE DATABASE SCOPED CREDENTIAL PolyBaseCredential WITH IDENTITY = 'PolyIdentity', SECRET = '<key from Azure>'; 
CREATE EXTERNAL DATA SOURCE PolyBaseDS WITH (TYPE = BLOB_STORAGE, LOCATION = 'wasbs://polybasetest@myblobcontainer.blob.core.windows.net/', CREDENTIAL = PolyBaseCredential ); 

When I tried creating external file format and  table,I am getting error.

CREATE EXTERNAL FILE FORMAT csvformat 
WITH ( 
    FORMAT_TYPE = DELIMITEDTEXT, 
    FORMAT_OPTIONS ( 
        FIELD_TERMINATOR = ','
    ) 
);

Msg 102, Level 15, State 1, Line 8
Incorrect syntax near 'EXTERNAL'.

CREATE EXTERNAL TABLE [Avengers]
(
        NAME [nvarchar](255) NOT NULL,
        LASTNAME [nvarchar](255) NULL,
        Email [nvarchar](255) NULL
)
WITH (DATA_SOURCE = PolyBaseDS)
GO 

Msg 102, Level 15, State 1, Line 8
Incorrect syntax near 'EXTERNAL'.

Can anyone help please? I tried creating Data source with Type= HADOOP but it threw error -incorrect syntax near Hadoop.So I tried TYPE=BLOB_STORAGE.

Questions about SQL Server Migration

$
0
0

Hello Experts,

I migrated the SQL Server 2014 to a new environment. The new environment operating system and SQL Server version are same as the old. --> Windows Server 2012 R2, SQL 2014

The CPU and memory are all better than the old environment.

Why SQL Server performance is slower than before. All queries are slow than before. However after about one week, the performance become fast. Everything works well.

Any ideas on this? Thanks in advance.


SQL Server Agent Job fails when using OPENROWSET

$
0
0

Hello Team,

I'm having issues with one of our SQL Server Agent Jobs that import data from an Excel sheet to a SQL Server table.

The query have

SELECT *

FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',

'Excel 12.0;Database=\\zzz\yyy\xxx\wwwt\Import.xlsx;',

'SELECT * FROM [report$]')

And it gave the error below:

Date  5/21/2018 11:33:35 AM
Log  Job History (Hours Update3)
Step ID  1
Server  SQLW16-01
Job Name  Employee Hours Update3
Step Name  Update / Insert Employee Hours in [1AAA] Table
Duration  00:00:01
Sql Severity 16
Sql Message ID 7412
Operator Emailed 
Operator Net sent 
Operator Paged 
Retries Attempted 0

Message
Executed as user: aaa\SQL_Agent.srv. Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". [SQLSTATE 42000] (Error 7303)  OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error". [SQLSTATE 01000] (Error 7412).  The step failed.

If I run the OPENROWSET or the SPROC that contains that, it runs perfectly fine without any issue or error. It only fails when it's being run on a Job. I also logged in to a computer as aaa\SQL_Agent.srv and it have read/write permission to the Excel file.

Anythoughts? Thank you in advance.

~Louie

Non-yielding Scheduler

$
0
0

I am on SQL 2014 SP2, no CU, latest GDR.

I checked and SP3 looks like fixed this (here https://support.microsoft.com/en-ca/help/4338890/sql-server-appears-unresponsive-and-non-yielding-scheduler-error-occur) .

Is there anything else I should do before I deploy SP3? I only had one incident of this in 1 year.

Error that I got

DoMiniDump () encountered error (0x80004005) - Unspecified error
Process 67:0:2  Worker 0x00000009AB20E160 appears to be non-yielding on Scheduler 0. Approx Thread CPU Used: kernel 0 ms, user 72521 ms. Process Utilization 25%. System Idle 70%. 
External dump process return code 0x20000001.
External dump process returned no errors.

[INFO]          Identity             Begin               End |        State                  Result     Error  Speculate   Prepared LazyCommit   ReadOnly |      Transaction         Database          ThreadId |   ReadSet  WriteSet  ScanSet Savepoint LogSizeRq | CommitDep TotalComm       Dependent 0       Dependent 1       Dependent 2       Dependent 3       Dependent 4      Dependent 5       Dependent 6       Dependent 7 |            Area  Location |
***Unable to get thread context for spid 0
* *******************************************************************************
*
* BEGIN STACK DUMP:
*   10/24/19 10:07:00 spid 3108
*
* Non-yielding Scheduler
*
* *******************************************************************************

Thank you,

How does SQL allocate indexes with nvarchar in the index key column

$
0
0

Fellow SQLers.

I am trying to find out what SQL does internally with this scenario and cannot find an answer to my liking in BOL or other places.

SQL 2016

Lets say you have a nvarchar(30) field that you need to have an Non Clustered Index on.

That internally is 60 bytes.

Lets say I am talking about a 12 byte record(althought it does not matter).

Does SQL actually RESERVE 60 bytes for the index row (plus overhead for nvarchar)  but uses only the actually Unicode size for the data and leave the remaining space as unused?

For example

Reserved 60, used 24, unused 36. I know this is not exact.

Is this correct?

Thanks

MG

DBA Questions

$
0
0

Hello all,

I faced following DBA questions which I could not answer. Please help.

1. Due to which db setting the log file size does not reduce on running shrinkfile command just after making the log file size          100 gb or so due to heavy transaction ?

2. What is the reason of persistent db restoring activity even after it is shown that the restore is 100% ?

3. What to do if master db crashes ?

4. Can we restore msdb ?

5. How to check the versions of all the db servers in a network from ssms at once ?

6. How to transfer users and jobs from one server to another ?

7. What is file sharing in alwayson ?

Tempdb space issue

$
0
0

Hi All,

One of the prod env, we are seeing high utilization of Tempdb and eventually hitting Tempdb drive full.

We increased the drive size by 100 Gb twice but still we are seeing same drive full errors due to tempdb every weekend. We have captured the usage using sp_whoisactive and provided the details to dev team to optimize their queries but there is no action taken by that team.

DBA team, has created an alert of Tempdb usage and if free % less than 20, we get the Tempdb data file usage per file and eventually we had to kill those txns. Again, this is due to specific txns which are run over the weekends.

Now, what I want to know is , as a DBA what should be done to avoid such issues apart from keep increasing the Tempdb drive size each and every time. Also, trying to understand how much should be the Tempdb drive size ?


Thanks,

 Sam

Permissions problem: Cannot process the object ""databasename"."dbo"."tablename"". The OLE DB provider "SQLNCLI11" for linked server "servername" indicates that either the object has no columns or the current user does not have permissions on that object

$
0
0

I have what I think is a permissions problem in a new database environment.

I have a table T1 in database DB1 on database server DBS1 that user U1 in DBS1 has the ability to read.  It has the db_datareader role for DB1.

I have a linked server LS1 on database server DBS2 that points to DBS1 using the SQL Server account for user U1.

When I run a select query using 4-part naming on DBS2 that … "select * from [LS1].DB1.dbo.T1"

I get an error: 

Cannot process the object ""DB1"."dbo"."T1"". The OLE DB provider "SQLNCLI11" for linked server "LS1" indicates that either the object has no columns or the current user does not have permissions on that object.

At 1st I thought the problem was that I was in SSMS with Windows account which does not have access to DBS1, but I then got the same error connecting to DBS2 via SSMS with the U1 SQL account.  I thought all that mattered was the SQL account in the linked server definition.

We also have scheduled jobs on DBS2 that uses the linked server LS1 every night successfully.


SQL Server 2008 Link Compatibility with Oacle19C

$
0
0

Hi,

I have many DB link from SQL Server 2008 to Oracle11G and vice verse. My company planning to upgrade Oracle from 11G to 19C. Can you please let us know is there any compatibility issue?

or do you have any SQL Server-Oracle compatibility matrix.

Regards,

Deepak


SQL Server Agent Job Notifications Not Working

$
0
0
We have successfully setup Database Mail, and I am able to right click and 'Send Test E-Mail' and it works perfect. We have a few jobs setup in SQL Server Agent, and if the job fails it should e-mail us. Recently a job failed, but no e-mail. So I looked at the job log and see:

NOTE: Failed to notify 'Development' via email.

I confirm under Operators we have `Development` with the e-mail address I would like the error message to go to. Any ideas what would cause this?

System_health XE reports

How much RAM should I dedicate to a SQL instance on a server(Question about SQLmax Formula)?

$
0
0

Hi experts,

  I have a dedicated Server(HPE DL580) with 3TB DRAM. According to https://sqlmax.chuvash.eu/, I should allocated 2,649,800 MB to the dedicated SQL Server. But is it right choice? I have 423GB available memory constantly and I think maybe I can allocate more memory to SQL Server, e.g. 2.8TB and leave maybe 200GB for OS is enough.

  Where is this formula coming from? I can't find any Microsoft documents mentioning this?

----

SQL Max Memory = TotalPhyMem - (NumOfSQLThreads * ThreadStackSize) - (1GB * CEILING(NumOfCores/4))
NumOfSQLThreads = 256 + (NumOfProcessors*- 4) * 8 (* If NumOfProcessors > 4, else 0)
ThreadStackSize = 2MB on x64 or 4 MB on 64-bit (IA64)



How to change the MSSQLSERVER Service Startup Account from NT Service\MSSQLSERVER to custom Windows account ?

$
0
0

Hello


Can you let me know an easy method to change the MSSQLSERVER Service Startup Account from NT Service\MSSQLSERVER to a custom Windows account in 2016 version ? Here are my requirements.


1) Create a new Windows O.S account called sqlserver_owner.

2) But do Not make it part of the administrators group.

3) Create an SQL Server login principle with SYSADMIN fixed server role for this sqlserver_owner account. 

I went to SQL Server configuration manager and chosen the SQL Server (MSSQLSERVER) account => right click and tried to change from NT Service\MSSQLSERVER to sqlserver_owner. It changed it. 

4) Now when i login to the Windows server using sqlserver_owner, i am not able to stop and start this service. When i try from windows component services, the stop and start buttons are greyed out.  When i try to click on SSMS => right click => restart , it asks for Administrator's password.

Basically, i would like to use a custom Windows login name as the MSSQLSERVER service owner, but not make it part of Windows administrators group.  Is it not possible in SQL server 2016 version ?

For audit compliance databases, i do not want to make it part of Windows administrators group for segregation of duties. The DBA login should not be part of Windows administrators group

I have seen this article https://msdn.microsoft.com/en-us/library/ms143504.aspx , but it has several steps and a series of permissions to be granted to sqlserver_owner to make it equal in nature to NT Service\MSSQLSERVER . But that is very lengthy and I hoping for a simple solution.

In older versions such as 2008, all that i had to do was add to SQLServerMSSQLUser$ComputerName$InstanceName and SQLServerSQLAgentUser$ComputerName$InstanceName groups.

-Srini


Trying to understand Trasaction behavior

$
0
0
Hi All,

Today, I got a case related to transaction behavior on SQL Server.
One of our Informatica ETL developer came back saying there is some problem with the sql database.
I went on call to try to understand what she was saying.

Problem description:
They have one table and try to load some data using Informatica ETL tool.
Using Informatica ETL Tool, they have written a simple transformation logic to load data. (truncate & load).

Table structure
==============
create table test_tbl
(
    id         varchar(100) null,
    last_update_date     datetime2(7) null
)
create unique clustered index pk_test_dbl on test_tbl(id asc);
go

For sake of testing, they are loading 1000 recs and trying to load 2 additional records (intentionally to reproduce a duplicate record).

Something like below

Truncate table test_tbl;

Insert into test_tbl
select top 1000
c1,c2 from srcdb.dbo.stg_tbl
union
select '9999','2019-10-30 00:00:00'
union
select '9999','2019-10-30 00:00:00'     --- simulate a duplicate record


Questions :
scenario 1 : when they run the ETL Tool pointing to dev server ,dev db, they see expected behaviour i.e. 1001 rows loaded and 1 rec is rejected as it is a duplicate 1. (i.e. 9999 )
scenario 2: when they change the connection, this time pointing prod server, prod db, they seeing different behaviour. They see only 700+ rows are getting inserted in prod table and not 1001.
                    they were asking why? it's the same truncate and load , works in dev perfectly and why it is not working the same for prod db?

To isolate the issue, I want to do some tests in SSMS, to remove the informatica tool out of picture.

CASE 1:
Ran below statements against dev and prod, I see the transaction behaviour as same (. i.e. SQL is considering the whole thing as single transaction, even 1 record fails, the entire txn is rollbacked. )

truncate table test_tbl;
go

Insert into test_tbl
select top 1000
c1,c2 from srcdb.dbo.stg_tbl
union
select '9999','2019-10-30 00:00:00'
union
select '9999','2019-10-30 00:00:00'     --- simulate a duplicate record

Msg 2601, Level 14, State 1, Line 11
Cannot insert duplicate key row in object 'dbo.test_tbl' with unique index 'pk_test_dbl'. The duplicate key value is (9999).

select * from test_tbl
--no rows


CASE 2 : I have trunacted the table and try to insert only 2 rows . here, this time 1 is getting inserted and 1 row rejected. Infact, i was expecting above error as CASE 1.
truncate table test_tbl
go


Insert into test_tbl
select '9999','2019-10-30 00:00:00'
union
select '9999','2019-10-30 00:00:00'     --- simulate a duplicate record

(1 row(s) affected)

select * from test_tbl
id        last_update_date
9999    2019-10-30 00:00:00.0000000


Can anyone explain this transaction behavior of sql server and ssms ? What is the batch size in sql server to commit or rollback? The reason why I am asking this is, If I try to insert 2 rows , I don't see any error. why ????
Once I get know the exact sql behaviour then I go back to the team and tell this is how sql server treats batch's and if there is something needs to be tweaked in terms of batch size or any db setting in inform them accordingly.

Environment details
==================
select @@version
Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64)
    Aug 15 2017 10:23:29
    Copyright (c) Microsoft Corporation
    Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)



Thanks,
Sam
Viewing all 15264 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>