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

calling a SP on remote server - without using a linked server

$
0
0

Hi all. 

I need to call a SP residing on SERVER1 from server2. Normally I would create a linked server from server2 pointing at server1. If I wish not to use a linked server to achive the same what other possibillities do I have ? 


Unable to connect to RDS PostGres

$
0
0

I want to access my DB on AWS RDS Postgres from the SQL Server. I have made the linked Server connection, connection was successfully established and I can see the AWS RDS Postgres tables. However, when I try to run the query through SSMS, i get the following Error.

                           

I have already tried SELECT * FROM OPENQUERY(DRIQ, 'SELECT TOP 100 FROM dr_iq.users') with no success. I have also unchecked the 'BOOL as Char' in the advanced option of datasource in the driver setting of 'system DNS'.

Please suggest any solution



Cross Database Ownership Chaining not working with AD Group

$
0
0

Hi

I have tried to figure this problem for some time now, and cannot get my head around it :-(

I am using MS SQL 2019 CU4 Std.

I want to use Cross Database Ownership Chaining between a couple of my databases, It works perfect if i:

  • Grant Connect to the Guest account
  • Grant connect to the AD user directly
  • Grant Connect to the AD Group [Domain Users]

But it does not work if i:

  • Grant Connect to an AD Group, where the user is a member

I have tried with more users but it fails always when I Grant connect to an AD group :-(

Does anyone have any idea how to solve this problem?

/Graves

SA account locked out

$
0
0
iam using Sql 2008 and my sa account is locked out and i cant get in or reset from command line, need help 

SelfHosted Integration runtime - ODBC AlwaysEncryption does not work for insert into Sink database

$
0
0

Hello,

We have Azure SQL Database with one of the column is been encrypted using ColumnEncryption features. CMK is stored in AzureKeyVault.

To perform copy between Source database to Sink database, we had to host a Self-Hosted Integration runtime with following packages into windows container.

  1. vc_redist.x64
  2. odbc 17 x64
  3. IntegrationRuntime x64
  4. .NET Framework 4.8 runtime x64

In ADF we have create 3 ODBC linked service pulling connection string from KeyVault, below is the connection string format we have usedODBC SQL Connection string: Driver={ODBC Driver 17 for SQL Server};Server=tcp:<sqlservername>.database.windows.net;Database=<databaseName>;ColumnEncryption=Enabled;KeyStoreAuthentication=KeyVaultClientSecret;KeyStorePrincipalId=<redacted>;KeyStoreSecret=<redacted>

both source and destination is having similar connection string, however, when we run the Copy Activity, source is successfully able to pull the data and decrypt the column data, but when activity is trying to write the data to the table via the sink we get following error

{
    "errorCode": "2200",
    "message": "Failure happened on 'Sink' side. ErrorCode=UserErrorOdbcOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=ERROR [22018] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Operand type clash: nvarchar(max) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = '<redacted>', column_encryption_key_database_name = '<redacted>') is incompatible with nvarchar(19) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = '<redacted>', column_encryption_key_database_name = '<redacted>')\r\nERROR [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared.,Source=Microsoft.DataTransfer.ClientLibrary.Odbc.OdbcConnector,''Type=Microsoft.DataTransfer.ClientLibrary.Odbc.Exceptions.OdbcException,Message=ERROR [22018] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Operand type clash: nvarchar(max) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto10', column_encryption_key_database_name = '<redacted>') is incompatible with nvarchar(19) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = '<redacted>', column_encryption_key_database_name = '<redacted>')\r\nERROR [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared.,Source=msodbcsql17.dll,'",
    "failureType": "UserError",
    "target": "Copy To Staging",
    "details": []
}

what i understand is ODBC driver is overwriting my flag ColumnEncryption=Enabled to ColumnEncryption=ResultsetOnly;

What am I missing here?


I have used Authentication=KeyVaultClientSecret and ClientId has all the required permission on KeyVaults; 



Providers for Linked Servers on Linux SQL Server

$
0
0

I have installed Ubuntu 16.04 and MSSQL server (including the ODBC driver).

I need this server to connect to an Azure database so the MS ODBC driver is installed. I set up the details of the Azure server in odbcinst.ini and odbc.ini (in /etc/ and also /opt/microsoft/msodbcsql/etc/). I have tested the ODBC connection using isql and it connects up and I can retrieve data from the Azure tables.

I then connect to the linux MSSQL server using SQL Management Studio and try to set up a linked server to the Azure database and this is where I have the issue.

When I go to create the Linked server it only shows an option to connect to an SQL server which it does not like. I have set this up on a Windows server successfully and the only difference I can see is that the Windows server has a list under Providers whereas the linux one does not.

Does anyone know how to add Providers on a linux server?

Many thanks

Unable to access remote sql server on local machine.

$
0
0
I am using Azure VM with Windows 10 and right now unable to access remote sql server on local machine. please urgent help required.

Data Capture .... Where/How?

$
0
0

I posted this in the Community Form and they suggested I repost here...

I am unclear how to work within the MS framework for this.  Or what approach I should consider.  

In simplest terms I can, the issue is I have a SQL Server on premise.  I use MS Access as a front end tool to SQL for ease of development.  My field techs are using PowerApps to update the SQL Server in real time.  Clients are completing forms to register in SQL Server.  All this is great and with a bit more time will all be working completely.

I am now moving onto suppliers.  For suppliers I would like to issue them a form similar to the client i.e. name, address, phone etc.  However I then have an associated table in SQL Server for AssociatedDetails.

AssociatedDetails are things like Road Freight Charges, Minimum Order Value, Prompt Payment Discounts etc.

Any supplier may offer/charge one or more associated item.  For example a supplier call him Fred, offers a prompt payment discount of 5% for orders over $500.00, charges a road freight charge of $30.00 a delivery and has a minimum order of $150.00.  Another supplier call him John may only have a flat freight charge of $40.00.  Yet another supplier call them Other have a road freight charge, a 3 kg air bag charge, a 5 kg air bag charge etc.

I went to Forms to make a form with a plan to use a Flow to pop back to SQL, and realised this wont work for the above possibilities.  The form structure relies on each supplier offering the same things and whilst this approach is perhaps possible with a complete listing of all the different options in AssociatedDetails it isn't a very elegant approach.

What other options are there for a public editable form?  A PowerApp could do this but is limited to only my team.  


select distinct records

$
0
0

Have a data extraction SQL that reads data from multiple tables. Most payroll numbers occupy only one position but Person D and F have unique Payroll number but occupy two positions.

Since Person D and F have more than one position they are retrieved twice I need to retrieve only one position, the first one will do. 

My SQL goes via tables PERSON >> POSITION >> PAYROLL >> etc.

Any assistance much appreciated.

First NameLast NamePosition NoPayroll NoSupervisor
Person A25325555 Sup1
Person B24253416 Sup2
Person C21883140 Sup3
Person D23803143 Sup4
Person D22663143 Sup5
Person E16422273 Sup6
Person F20593005 Sup1
Person F10863005 Sup1


Linked Server to DB2: Codepage conversion error

$
0
0

Hi, everybody!

 

The Situation:
This is a followup to a question I asked before regarding linked server.

I created a linked server to a DB2 database using the IBM OLEDB Provider for DB2 (“IBMDADB2”). The creation of the linked server returned no error.

When I submit the command
UPDATE DB_Test.Database.Schema.Table SET Column=N'f****t' WHEREID= 1
--or alternatively the command below
UPDATE DB_Test.Database.Schema.Table SET Column='f****t' WHEREID= 1

 I receive the error message
OLE DB provider "IBMDADB2.DB2COPY" for linked server "DB2_TEST" returned message "[DB2] SQL0332N Character conversion from the source code page "1208" to the target code page "65534" is not supported. 
SQLSTATE=57017".
OLE DB provider "IBMDADB2.DB2COPY" for linked server "DB2_TEST" returned message "[DB2] SQL0332N
 Character conversion from the source code page "1208" to the target code page "65534" is not supported. 
SQLSTATE=57017".
Msg 7320, Level 16, State 2, Line 1
Cannot execute the query "UPDATE "Database"."Schema"."Table" set "Column" = G'f****t'
 WHERE "ID"=(1)" against OLE DB provider "IBMDADB2.DB2COPY" for linked server "DB2_TEST".

 

The Problem:
Please note the UPDATE statement returned by the error message: SQL Server added a “G” to the string ‘f****t’, which indicates a character conversion to a DB2 specific data type called “Graphics”.  According to my experiments in Visual Studio with ADO.NET and the provider IBMDADB2 the additional “G” produces this error; the same command without the “G” works out fine! Visual Studio uses the provider and does not show up with an additional “G” when using the UPDATE statement described above.

The update of a number or date based column works fine, too!!!!

 

My Question:
How can I avoid the addition of the “G” to the string when using linked servers?


I am using:
OS: Windows 2008 R2 64 bit
DB: SQL Server 2008 64 bit
DAM: IBMDADB2 64 bit

This is the linked server definition:

IF EXISTS(SELECT srv.nameFROMsys.servers srvWHERE srv.server_id!= 0 AND srv.name=N'DB2_OLEDB')
EXECmaster.dbo.sp_dropserver@server=N'DB2_OLEDB', @droplogins='droplogins'


EXECmaster.dbo.sp_addlinkedserver@server =N'DB2_OLEDB', @srvproduct=N'DB2', @provider=N'IBMDADB2.DB2_NEMOS3000', @datasrc=N'Database', @location=N'server.domain.tld:12345', @provstr=N'Provider=IBMDADB2.DB2_NEMOS3000;Database=DB2_Database;Protocol=TCPIP;Hostname=server.domain.tld;Port=12345;UID=user;PWD=password'

EXECmaster.dbo.sp_addlinkedsrvlogin@rmtsrvname=N'DB2_OLEDB',@useself=N'False',@locallogin=NULL,@rmtuser=N'user',@rmtpassword='password'


EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'collation compatible', @optvalue=N'false'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'data access', @optvalue=N'true'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'dist', @optvalue=N'false'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'pub', @optvalue=N'false'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'rpc', @optvalue=N'false'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'rpc out', @optvalue=N'true'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'sub', @optvalue=N'false'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'connect timeout', @optvalue=N'0'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'collation name', @optvalue=null

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'lazy schema validation', @optvalue=N'false'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'query timeout', @optvalue=N'0'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'use remote collation', @optvalue=N'true'

EXECmaster.dbo.sp_serveroption@server=N'DB2_OLEDB', @optname=N'remote proc transaction promotion', @optvalue=N'true'


Using "like" statement in order to filter DATE field SQL SERVER 2014

$
0
0

Hello, could somebody help me in using "like" statement in filtering DATE field in SQL SERVER table. Namely, in C# web application, I have this date format e.g., 20-Dec-19 while, in SQL SERVER table it is written as: 2019-12-20!

Having on mind that I need to filter e.g., all the dates from a year e.g., from 2020.year. Further on, upon having performed copy/paste of date format from the SQL SERVER 2014 table, into Filter column while in EDIT table option, it is converted into this format: '12/20/2019'. I am having troubles to figure out which is which in mentioned issue:

Please, what to do to filter e.g., all the dates from the selected year?

thank you!

Create linked server to SYBASE ASA 9.0

$
0
0

 

Hi all,

 

I´m trying to create a linked server to a Sybase database (.db file) so i can create some reports in sql 2005 (with Reporting Services and Report Designer). After reading all articles I did the following.

 

1) Installe Adaptive Server Anyhwere (Interactive Sql) 9.0.2 on the server.

2) Created a USER DSN to the Db file (Control Panel - odbc connections) and it works fine: The Settings for the ODBC are:

  • ODBC Tab
    • Data Source Name: dbNOM
  • Login Tab
    • Supply userID and Password: (selected)
    • User ID: DBA
    • Password: SQL
  • Database Tab
    • Server Name: dbNOM
    • StartLine: C:\Program Files\Sybase\SQL Anywhere 9\win32\dbeng9.exe
    • Database Name: (blank)
    • Database File: c:\Project Folder\DataBase.db

As I said, when i go for "test connection", works fine.

 

3) Sql Management Studio - Object Explorer - Server Objects - New Linked Server, with settings as following:

  • General
    • Linked Server: lkDbNom
    • Server Type: Other Data Source
    • Provider: Sybase Adaptive Server Anywhere Provider 9.0
    • Product Name: Sybase
    • Product Name: dbNom (the dsn name, right?)
  • Security
    • Be made using this security context.- Remote Login: DBA; Password: SQL (same as DSN)

All other settings, as default, click in OK and shows no errors (aparently it creates the linked server successfully). But when i try to query the linked server with:

 

SELECT

*FROMOPENQUERY('SYBASE','SELECT * FROM nom_Robot')

 

And i get the following message:

 

Msg 102, Level 15, State 1, Line 1

Incorrect syntax near 'SYBASE'.

 

Even better, if i go to the Object Explorer - Server Objects, i test the connection and it´s ok, but when i try to retrieve the catalog an error displays:

 

TITLE: Microsoft SQL Server Management Studio
------------------------------

Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

The OLE DB provider "ASAProv.90" for linked server "SYBASE" reported an error. Access denied.
Cannot obtain the required interface ("IID_IDBSchemaRowset") from OLE DB provider "ASAProv.90" for linked server "SYBASE". (Microsoft SQL Server, Error: 7399)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3054&EvtSrc=MSSQLServer&EvtID=7399&LinkId=20476


 

So, i really don´t understand what is missing in my linked server, i tried with MDASQL (OLEDB for ODBC) but it doesn´t even completes to create the linked server.

 

The database file is ok because, because in another server (one that doesn´t have SQL, only visual studio) i did the following:

 

1) Installe Adaptive Server Anyhwere (Interactive Sql) 9.0.2 on the server.

2) Created a DSN to the Db file, and it works fine. (copied the db file, so is local, no remote access), exactly the same setting as i did on the sql 2005 server.

3) C

reated a connection in visual studio 2008  (server explorer - data connections), i can retrieve sdata...but of course the provider is  .NET Framework Data Provider for ODBC and i cannot use the same connection string.

 

Any ideas?

 

P.S.

VBA wrongly throws errors after upgrading SQL Server to version 14.0.2027 RTM from version 10.50.2500 SP1

$
0
0

Hi there,

When using the new SQL Server, our Access Front End throws different writing conflict errors when executing code that involves writing to a table that contains a SQL Server trigger. If I disable the trigger no errors are generated.

But curiously enough, the VBA code that inserts/updates the record is successful, and so are the table updates that the trigger actions.

So it seems to me that this is a bug.

Any help,

Thanks

How to install 32-bit linux version odbc driver for sql server (azure sql mi)

$
0
0

My partner want to connect to azure sql MI on linux system, and they need 32 bit version.

Current SQL Server ODBC Driver is version 17 and provided just one package for both 32 bit and 64 bit system.

So how to just install the driver with 32 bit Linux support.

Or where is the 32 bit driver download url?

Powershell connexion failed

$
0
0

Helo,

I am new to SQL Server and I am trying to connect remotely from a server (A-SERV) to my SQL Server (B-SERV) with PowerShell.

It fails every time.

Here is my little code:

$sqlConn = New-Object System.Data.SqlClient.SqlConnection
$sqlConn.ConnectionString = “Server=B-SERV;Integrated Security=false;User ID = 'XXXXXXXXXX' ; Password = 'XXXXXXXXXX' ;Initial Catalog=XXXXX; trusted_connection = true”
$sqlConn.Open()
Invoke-Sqlcmd -Query "SELECT * FROM [mdt].[dbo].[deploiements]"
$sqlConn.Close()

The weird thing is that I can connect with SQL Server Management Studio (SSMS) from A-SERV and do it manualy.

The second thing is that my PowerShell script works fine when launched on the database server (B-SERV), but not from A-SERV.

"allow remote connections to this server" is ticked in SSMS server's properies.


I am lost and a noob. Any clue ?
scuz my english.




postgresql Severity.error : Unsupported authentication type 3, closing connection

$
0
0

I created a flutter applications and plans to use Azure postgresql as the database. I used a dart package that connects with the database. Package is called postgres 2.1.1. However, as I try to connect, it prompts an error postgresql Severity.error : Unsupported authentication type 3, closing connection.I have disabled ssl and configured the firewall, opened port 1433 but to no avail. I was able to connect to the database via pgadmin but not through the package. Error throws at line 2. 

var connection = new PostgreSQLConnection("postgresqlgreen.postgres.database.azure.com", 5432, "postgresqlgreen", username: "greenscanneradmin@postgresqlgreen", password: {admin_password});


await connection.open();


 

SQL Server High Availability and ODBC drivers

$
0
0

Hi, we have a client using SQL Server 2016 using the High Availability option (they are using primary and secondary servers). We are having problems (intermittently) when our client application connects (we get a State:S1T00 error). It looks like our client is using a SQL Server ODBC driver v10.

Is it possible to use this driver for connection when using SQL Server High Availability, or do we have to use a later driver (ie, v11 or above)? The client does connect, but it seems to be intermittent (and I'm wondering if it's not connecting when the High Availabilty is maybe switching between primary and secondary?). 

Thanks, Peter

Can somebody hack the database from Azure ?

$
0
0

Hello everyone,

 I have a question about settings of our Azure SQL database.

We have default settings.

Allow Azure Services and resources to access this server = YES

And we also have defined some IP addresses.

My question is, if we have "allow azure services and resources to access this server = yes" if there is possibility, that someone who stole/hack password login to SQL database, should access to this database via some Azure vPC, or Azure APP.

For standard users, there are IP ranges, but if somebody try to connect via some Azure service from another subcription, is it possible, or he cant connect, because isnt defined in IP adress range, and only services from same subscription could connect to this SQL.

There are 3 potential situations:

app/vPC from same subscription - is it possible to hack SQL ?

app/vPC from another subscription, but same tenant - is it possible to hack SQL ?

app/vPC from another subscription and another tenant - is it possible to hack SQL ?

Thank you for clarify it.

How can I access a SQL DB on a SQL Server in Azure from a docker container?

$
0
0

The docker container gets environment variables passed:

DB=mysql
   MYSQL_HOST=<MySQL hostname>
   MYSQL_PORT=<Port>
   MYSQL_USER=<Username>
   MYSQL_PASSWORD=<your secret>
   MYSQL_DB=<NameOfDatabases>

https://hub.docker.com/r/simplifierag/runtime

But pre-handshake fails. Firewall rules allows azure instances and my client IP to access the DB, also the docker container IP is allowed. How can I achieve access to the SQL DB on the Azure SQL Server?

Reconnecting to database after fresh install

$
0
0
I reinstalled my OS fresh and am trying to reconnect to my databases that were installed in the previous installation of SQL Server 2017. It was windows authentication and my credentials have changed. I have no back up of the databases but am wondering if its possible to reconnect the databases to the new installation of SQL Server.
Viewing all 4164 articles
Browse latest View live


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