Quantcast
Channel: SQL Server Data Access forum
Viewing all 4164 articles
Browse latest View live

How to find if disk I/O utilization for SQL Server

$
0
0

Hi,

We have a SQL server 2012 instance where 11 databases are hosted. In the host 2 Intel Xeon CPU & 512 GB RAM is installed. But application team complaining slowness from database. We are suspecting high disk I/O utilization of the disks. Can anyone tell me how can we see & measure disk I/O utilization of the windows disks and how can we identify is there any anomaly in the disks?


SQL 2016 using $SMOserver PowerShell object takes a lot of time to retrieving Database information

$
0
0

Hello,

I am using $SMOserver PowerShell object to retrieve database information from SQL 2016, but it takes around 20 minutes; I ran the same script on SQL 2014 environment, into it, the script takes around 1 minute; I searched information about differences between SQL 2014 and SQL 2016 but, I didn’t found information to explain that behavior.

I am using Windows credential with Public role only; for sysadmin role, the script takes around 5 min.

Bellow I send the script that I am using:

 

$sw = [Diagnostics.Stopwatch]::StartNew()
$instance_name = 'MSSQLSERVER'
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
$dbs = (New-Object ('Microsoft.SqlServer.Management.Smo.Server') -argumentlist "$($env:computername)\$($instance_name)").Databases

if ($dbs -ne $null)
{
    foreach ($data_base in $dbs)
    {
        $Used = 0
        $Size = 0
        echo "Database Name: $($data_base.Name)"
        try{
            if ( $data_base.LogFiles -ne $null ) {
                foreach ($log in $data_base.LogFiles) {
                    $logUsed += $log.UsedSpace
                    $logSize += $log.Size
                }
            
                echo "  UsedSpace: $($Used)"
                echo "  Size: $($Size)"
            }
        }catch{}
    }
}
$sw.Stop()
$sw.Elapsed


cannot connect anymore with Microsoft ID (outlook.com) on SQL Server Express

$
0
0

Hi There,

I have an SQL Server Express on a server running windows 10. It was configured with integrated authentication only.

I have a client also running windows 10. I am using Microsoft ID (outlook.com) login for authentication. Connecting from the client to the server with SSMS was working fine until yesterday (or maybe earlier since I don't connect everyday remotely) : I get a "cannot create SSPI context error."

The issue comes from this integrated authentication as I successfully tested with SQL Server login. The outlook.com user is known on both the server and the client. Connecting with the same user using SSMS on the server works fine.

My assumption is that now, instead of sending Microsoft ID information to the server, the client sends the local "client\user" associated to my Microsoft Id, which is different from the "server\user" I found in the server connections. Still assumptions, using a Microsoft ID would be deprecated and we now have to use an Azure AD login.

Switching to AD user would mean changing my authentication on my server and all my clients, loosing al my profile info, etc. which seems a huge impact.

So I'd like to get back my authentication with Microsoft ID

Can anyone please advise?

Thank you in advance for your help

Cedric

How to find Table and Index fragmentation in SQL Server?

$
0
0

Hi,

I am using SQL Server 2012. I want to find the table and index fragmentation so that I can reclaim the fragmented space. Can anyone tell me how can I find that?

I have done in Oracle database. I want something similar like this. below is the link-

http://select-star-from.blogspot.com/2013/09/how-to-check-table-fragmentation-in.html

SQL Server Data Access

$
0
0

Dim constring = "Driver = {SQL Server Native Client 11.0}; Server= DESKTOP-8OLDD1Q;
        Database = " & dsource & " ; Trusted_Connection = yes"

This connection string does not work. It triggers the error:

An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll

Additional information: Keyword not supported: 'driver'.

Any comments?


Chandrasekharan Kunnath

Connection String SQL Server

$
0
0

I have a project in Visual Studio 2015 It uses SQL Server 2016. I have tried some connection strings but they result in an error. One of them is that the keyword "Provider" is not valid. When I remove that from the connection string, the error is that the login has failed.

This is my connection string:

Dim constring = "Server = DESKTOP-8OLDD1Q; Initial Catalog = " & dsource & "Trusted_connection = yes"

What is wrong?


Chandrasekharan Kunnath

SQL Server OPENROWSET OLE DB provider “MSDASQL” for linked server “(null)”

$
0
0

first i configure ad hoc distributed queries with below query

EXEC sp_configure 'show advanced options',1RECONFIGURE
GOEXEC sp_configure 'ad hoc distributed queries',1RECONFIGURE
GOSELECT*FROMOPENROWSET('MSDASQL','Driver={Microsoft Access Text Driver (.txt, .csv)};
 DefaultDir=C:\CSV','select * from smdr.csv') T

and when i try to execute the above script then getting error

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

how to fix it....please guide me. thanks

SQL Server OPENROWSET OLE DB provider “MSDASQL” for linked server “(null)”

$
0
0
First i configure ad hoc distributed queries with below query
EXEC sp_configure 'show advanced options',1RECONFIGURE
GOEXEC sp_configure 'ad hoc distributed queries',1RECONFIGURE
GOSELECT*FROMOPENROWSET('MSDASQL','Driver={Microsoft Access Text Driver (.txt, .csv)};
 DefaultDir=C:\CSV','select * from smdr.csv') T

and when i try to execute the above script then getting error

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

how to fix it....please guide me. thanks


Try to export data to excel from sql server using OPENROWSET issue

$
0
0

i issue below script and got error Cannot create an instance of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

EXEC SP_CONFIGURE 'show advanced options', 1;
GO
RECONFIGURE;
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;

INSERT INTO OPENROWSET ('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=c:\CSV\testing.xlsx;',
'SELECT * FROM [Sheet1$]')
select top 10 * from Emp2

tell me how to fix it. i need to export data to excel file in UNC path. please guide me how to achieve it.

again i try below script too but this time getting different error Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

INSERT INTO OPENROWSET
   ('Microsoft.Jet.OLEDB.4.0',
   'Excel 8.0;Database=c:\CSV\testing.xlsx;','SELECT ID,Name FROM [Sheet1$]')
   select top 10 * from Emp2

please guide me how to export data to excel file which will be generated in UNC path.

thanks

Try to export data to excel from sql server using OPENROWSET issue

$
0
0

i issue below script and got error Cannot create an instance of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

EXEC SP_CONFIGURE 'show advanced options', 1;
GO
RECONFIGURE;
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;

INSERT INTO OPENROWSET ('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=c:\CSV\testing.xlsx;',
'SELECT * FROM [Sheet1$]')
select top 10 * from Emp2

tell me how to fix it. i need to export data to excel file in UNC path. please guide me how to achieve it.

again i try below script too but this time getting different error Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

INSERT INTO OPENROWSET
   ('Microsoft.Jet.OLEDB.4.0',
   'Excel 8.0;Database=c:\CSV\testing.xlsx;','SELECT ID,Name FROM [Sheet1$]')
   select top 10 * from Emp2

please guide me how to export data to excel file which will be generated in UNC path.

thanks

Table or Schema Backup in SQL Server

$
0
0
I can take full database backup using SQL Server Management Studio. Is there any way to take backup of specific table or schema?

ODBC drivers for Windows server 2016

$
0
0

We are beginning to use Windows Server 2016 as our base for servers.

But now I discover that no ODBC driver for SQL server is available for this server version.

When do Microsoft deliver an ODBC driver for x64 og x86 for Windows Server 2016?

Convert SP and function into business rule - Automatically

$
0
0

Hi,

I  have an excel that contain Techinical rule like this . I want to automatically generate Business rule like the column on left. 

Is there any tool to convert it ? Any C# or asp.net converter is there?

                                   Business rule                                            Technical rule

1. this function is used to get phone number from phones table on basis name id and name type
2. it accepts input parameters as

p_name_id number

p_name_type string 

and return phone as string 

function get_phone(p_name_id number, p_name_type varchar2) return varchar2 isv_pri_phone varchar2(15 Byte);begin        select p.phoneA || p.phoneB || p.phoneC  into v_pri_phone        from phones p        where p.name_id = p_name_id        and  p.NAME_TYPE = p_name_type        and   p.PHONE_SEQ = 1        and  p.ADDR_SEQ  = 1;    return v_pri_phone;EXCEPTION   WHEN no_data_found then          return(null);   WHEN  others       then          return(null);end get_phone;
1. this function is used to get payer type on basis of payer id 
2. get claim center type from claim center table on basis of payer id 

3. get payer type on basis of claim center type 

function get_payer_type(p_payer_id in number) return number isv_payer_type number(1);v_cc_type claim_centers.CCTYPE%TYPE;begin        select cc.CCTYPE into v_cc_type        from claim_centers cc        where cc.no = p_payer_id;        if v_cc_type in ('BC/BS','CARECNTRIX', 'COMMERCIAL', 'INS-HMO','INS-INDEMN','INS-PPO', 'INSURANCE','IPA','MEDCO CHAN',                         'RX CARDS','TRUST MGMT', 'WORK COMP') then           v_payer_type := 1;        elsif v_cc_type in ('MEDICARE','MGD MCARE','MC PART D') then           v_payer_type := 2;        elsif v_cc_type = 'FNL WAIVER' then           v_payer_type := 3;        elsif v_cc_type in ('CHAMPUS','FEDERAL') then            v_payer_type := 4;        elsif v_cc_type in ('MEDICAID','MGD MCAID','STATE PRGM') then            v_payer_type := 5;        elsif v_cc_type in ('SELF PAY') then            v_payer_type := 6;        else            v_payer_type := null;        end if;        return v_payer_type;EXCEPTION   WHEN  no_data_found         then return(null);    WHEN  others         then return(null);end get_payer_type;

Azure Sql Server Elastic DB

$
0
0

Hello,

I want to know more about sql azure elastic db. I guess single sql server can handle upto 250GB of data at affordable cost. We have large amount of data that can exceeds 250Gb. Should We use Azure sql Elastic DB? How to create that elastic db and how to query it through SSMS.?

What is sql server agent

$
0
0

please tell me What is sql server agent and what it does ?

in what kind of situation people think for agent


SQLCMD for Linux is missing in ODBC 13.

$
0
0

I followed the instructions to install the ODBC 13 Driver on a RHEL 7.2 machine. They are available as a downloadable PDF file here: https://www.microsoft.com/en-us/download/details.aspx?id=50420 . I also copied them below.

sudo su
yum-config-manager --add-repo https://apt-mo.trafficmanager.net/yumrepos/mssql-rhel7-release/
yum-config-manager --enable mssql-rhel7-release
wget "http://aka.ms/msodbcrhelpublickey/dpgswdist.v1.asc"
rpm --import dpgswdist.v1.asc
yum remove unixodbc #to avoid conflicts during installation
yum update
yum install msodbcsql
#for silent install use ACCEPT_EULA=Y yum install msodbcsql
yum install unixODBC-utf16-devel #this step is optional but recommended*

According to the SQL Documentation available here: https://msdn.microsoft.com/en-us/library/hh568447(v=sql.110).aspx , the sqlcmd tool is available on Linux and included in the driver package. I cracked open the RPM and sqlcmd is definitely not included. How do I get sqlcmd on my RHEL 7.2 environment?

What are difference between @@IDENTITY, SELECT SCOPE_IDENTITY(), SELECT IDENT_CURRENT in SQL Server?

$
0
0

i got info for @@IDENTITY, SCOPE_IDENTITY() and IDENT_CURRENT and those info as follows

SELECT @@IDENTITY: it’s responsible to returns the last identity value generated for any table in the current session, across all scopes (i.e. global scope).

SELECT SCOPE_IDENTITY(): It’s responsible to returns the last identity value generated for any table in the current session and the current scope(i.e. local scope).

SELECT IDENT_CURRENT(‘table_name’): It’s responsible to returns the last identity value generated for a specific table in any session and any scope (i.e. global scope).

still the difference between @@IDENTITY and SCOPE_IDENTITY() is not clear. what they try to mean global scope and local scope ?

thanks

How to prioritize a stored procedure over another on the basis of it's memory usage ?

$
0
0

Hi, 

I have a requirement where I have to execute two different stored procedure at the same time. In that the memory usage of both of the stored procedures are different. Now suppose sp-1 has a higher memory usage than sp-2, I want to execute sp-1 first with a greater memory space and at the same time sp-2 is either executing with a less amount of memory or get suspended for some time and after when the sp-1 is completed then sp-2 will execute with it's full memory space. There may be an additional condition where suppose we have enough memory for both of the stored procedures, in that case both should be get executed. Can I do it ? 

I really don't how to estimate the cost and how can I prioritize one over another. 

Please help !! Thanks in Advance :) 


What are ACID properties in SQL Server?

$
0
0

they said as follows but Consistency is not clear what they try to means for Consistency ?

The ACID rules of transaction in any database ensure the reliability of data in all transactions in the database.

Atomicity
Atomicity shows the ability of database to assure that either all tasks of a transaction are performed or none of them.

Consistency
Consistency assure that database remain consistent state before the transaction and after the transaction is over.

Isolation
Isolation assures that other operation can't be performed in an intermediate state during a transaction. As a result, transactions that run concurrently appear to be serialized.

Durability
Durability is responsible to notify the transaction is succeed; the transaction will persist, not undone.
It will survive system failure and the database system has checked the integrity constraints and no need to abort the transaction.

Select Permission Denied on object

$
0
0

 

Hello all,

I have just begun to develop a simple web application to maintain phone book / contact details of people. I have been facing problems wrt the connection to the database, while trying to execute the reader it throws this error -

Server Error in '/phonebook' Application.


SELECT permission denied on object 'PhoneBook', database 'Northwind', owner 'dbo'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SELECT permission denied on object 'PhoneBook', database 'Northwind', owner 'dbo'.

Error occurs at -

reader = cmd.ExecuteReader();

The stacktrace looks like this -

[SqlException: SELECT permission denied on object 'PhoneBook', database 'Northwind', owner 'dbo'.]
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
   System.Data.SqlClient.SqlCommand.ExecuteReader() +42
   Phonebook.ResultPage.CreateDataSource() in c:\inetpub\wwwroot\phonebook\resultpage.aspx.cs:56
   Phonebook.ResultPage.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\phonebook\resultpage.aspx.cs:39
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35

   System.Web.UI.Page.ProcessRequestMain() +750

 

I have tried managing permissions both on IIS as well as Enterprise Manager and given all rights to the admin. Please help me out

Thanks

Sanchita


 

Viewing all 4164 articles
Browse latest View live