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

Not able to Create ODBC DSN using Microsoft OLE DB Driver for SQL server(msoledbsql.dll)

$
0
0

I have Microsoft OLE DB Driver for SQL server installed in my system (Windows 2019 server), version- 18.2.2.0.

Also, I can see a dll available at this location "C:\Windows\SysWOW64\msoledbsql.dll". Along with it, the below folder structures also got created:

C:\Program Files\Microsoft SQL Server\Client SDK\OLEDB\182

Now my question is,I was trying to create ODBC DSN using Microsoft OLE DB Driver for SQL server but, I am not sure which driver I need to select. Below is the list of the drivers available in ODBC Data Source Administrator(64-bit) and ODBC Data Source Administrator(32-bit):

ODBC Data Source Administrator(64-bit):

SQL Server

ODBC Data Source Administrator(32-bit):

1. Driver da Microsoft para arquivos texto (*.txt; *.csv)

2. Driver do Microsoft Access(*.mdb)

3. Driver do Microsoft dBase(*.dbf)

4. Driver do Microsoft Excel(*.xls)

5. Driver do Microsoft Paradox(*.db)

6. Microsoft Access Driver(*.mdb)

7. Microsoft Access- Treiber(*.mdb)

8. Microsoft dBase Driver(*.dbf)

9. Microsoft dBase- Treiber(*.dbf)

10.Microsoft Excel Driver(*.xls)

11.Microsoft Excel-Treiber(*.xls)

12.Microsoft ODBC for Oracle

13.Microsoft Paradox Driver(*.db)

14.Microsoft Paradox-Treiber(*.db)

15.Microsoft Text Driver(*.txt; *.csv)

16.Microsoft Text-Treiber(*.txt; *.csv)

17.SQL Server

It would be very helpful if anyone can please help me out in this. Thanks in advance.





ODBC SSL Security Error

$
0
0

I am trying to set up a test environment. I need to connect an application server (Windows Server 2012 R2) to a SQL Server database (SQL Server 2005 SP4). The applications cannot connect to the DB server from this app server. They work fine on other application servers connecting to this DB. I tried creating an ODBC connection. I get the error below.

Every other server or desktop that I have tried to connect to this database works fine. I tried creating ODBC connections to other databases from this app server, and those work fine too. It seems to be only this particular connection that does not work.

We looked at the encryption settings, but those do not seem to be a factor in this. Maybe the "SSL Security Error" is misleading? How can I troubleshoot this?


Do I need to create a special role?

$
0
0

Hi everybody,

I want to allow some external people to be able to run various performance related views on our DB to help with the performance tuning (and give tips as how to optimize the DB). On the other hand, I don't want them to read the actual data in our tables (and, of course, modify the data).

I created a new login and then created a user with two roles (db_denydatareader and db_denydatawriter) and, of course, I can not even do anything after I login (cannot even run top 10 slowest queries query).

I looked into fixed roles and nothing seems to work.

What should I do? Do you have a sample of creating a role with enough permissions to perform the tasks I outlined but not enough permissions to read/modify data?

Thanks a lot in advance.


For every expert, there is an equal and opposite expert. - Becker's Law


My blog


My TechNet articles

SQL Server Restore

$
0
0

I am trying to restore a SQL Server 2000 backup to a SQL Server 2008 instance. The backup does not have an extension. I also used windows authentication when the backup was created in 2004 and no longer have access to the old Windows userID.

Server is on my local machine as well as the backup file. 

Here is what I am trying and the error I get. What am I missing? Do I need to rename the backup file?

RESTORE DATABASE  WorkOrderSystem FROM DISK = 
'C:\Backup\WorkOrderSystemDatabaseBackup'
with
MOVE 'WorkOrderSystem_Data' TO 'C:\Backup\WorkOrderSystem_Data.mdf',
MOVE 'WorkOrderSystem_Log' TO 'C:\Backup\WorkOrderSystem_Log.ldf';
Go
Msg 3201, Level 16, State 2, Line 1
Cannot open backup device 'C:\Backup\WorkOrderSystemDatabaseBackup'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

I have tried to give NT SERVICE\MSSQLSERVER  full control to c:\Backup. 

"Memory allocation failure" error using MSOLEDBSQL

$
0
0

We have a legacy VB6 application which we recently changed from SQLOLEDB to MSOLEDBSQL because our network admins want to disable TLS1.0.

Since then we're seeing the error "Memory allocation failure", we've never seen this in the 18+ years we've been using SQLOLEDB.  This happens to about a dozen users every day and there's no obvious pattern.  The VB6 application exclusively calls stored procedures, there's no "direct" queries/updates/inserts/deletes.  Another point worth noting is that the application creates a single connection on startup and uses this for everything, so typically the connection is active for the whole working day.  Here's the database connection code:

Set lobjConnection = New ADODB.Connection

With lobjConnection
    .Provider = "MSOLEDBSQL"
    .Properties("Data Source").Value = "MyServer"
    .Properties("Initial Catalog").Value = "MyDatabase"
    .Properties("Integrated Security").Value = "SSPI"
    .CursorLocation = adUseClient
    .Open
    .Execute "SET QUOTED_IDENTIFIER OFF"
    .Execute "SET IMPLICIT_TRANSACTIONS OFF"
    .Execute "SET CURSOR_CLOSE_ON_COMMIT OFF"
    .Execute "SET ANSI_WARNINGS OFF"
    .Execute "SET ANSI_PADDING OFF"
    .Execute "SET ANSI_NULLS OFF"
    .Execute "SET CONCAT_NULL_YIELDS_NULL OFF"
    .Execute "SET LANGUAGE US_ENGLISH"
    .Execute "SET DATEFORMAT DMY"
    .Execute "SET DATEFIRST 7"
End With

To be clear, there have not been any SQL Server configuration changes, the only change is from SQLOLEDB to MSOLEDBSQL in the client application.

Has anyone else seen this behaviour?  It's inconvenient and I'm not sure how to go about investigating it further.

Thanks in advance

Changing ODBC default database, but can't change

$
0
0
I have a issue with changing database using datasource.

Try steps
1.start odbc datasource administrator
2.configure 'change default database' checked and change database from A to B
3.save it

I confirmed registory HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\<DSN>\Database is 'B'
But application connect to database A.
Application not used 'Database' in connection string.

I would be grateful if you could get hints.
Please excuse my english, it's not my native language.

SQLSTATE = 08S02, SMux Provider Physical connection is not usable

$
0
0

A power user keeps getting this error, she's connected via client > database server. The DB server is a VM on ESXi 5.0 with a e1000 network adapter. I read an article of someone suggesting to change the nic to vmxnet3 if the VM is being hosted on ESXi 4, but we are running 5.0. We did not have a network disconnect at the time the user reported this error (14:57). About 4 other power user connect to the DB server and do not get this error (to add to the mistery). Only this one user keeps getting the error. 

Client: Windows 7 64 bit

DB Server: Win2008 R2, SQL 2008 R2 (10.50)

DB server VM on ESXi hypervisor version 5.0.0

Here's the error information:

Error Information

     Error Occurred On: 2014-05-21 14:57:57

     Error Type: Architecture Error

     Error Object Type: ds_psf_find_criteria.uf_save()

     Error Object: nvo_ext_datastore

     Error Message: Find|Criteria|Last Error:

 

SQLSTATE = 08S02

Microsoft SQL Native Client

SMux Provider: Physical connection is not usable [xFFFFFFFF].

 

No changes made to database.

 

UPDATE "dba"."find_criteria" SET "condition" = N'= %L%M%R' WHERE "criteria_id" = 455 AND "find_id" = 301

Product Information

     Product Name: Storer Information Management System

     Product Version: 5.000

     Product Build: 20140401

     Product Mode: Client

Installation Information

     Install Name: SIMSv41

     Install Directory: C:\StorerTV\SIMSv41

User Information

     User Name: cchubbuck

     User Id: 25

     Site Id: 607

     Station Id: 1224

Database Information

     Instance Name: PM-BROADWAYSQL

     Database Name: PARTICIPANTMEDIA

Security Database Information

     Instance Name: PM-BROADWAYSQL

     Database Name: SIMSSECURITY

Language Database Information

     Instance Name: PM-BROADWAYSQL

     Database Name: PARTICIPANTMEDIA

Open Window Information

     Window Name: StorerTV.SIMS.Messaging.MessageHandler [SIMSv41]

     Window Name: Storer Information Management System

     Window Name: General Search - PIVOT

     Window Name: Application Error

System Information

     Computer Name: WIN-0441

     User Id: cchubbuck

     CPU: Pentium

     OS Type: WindowsNT

     OS Version: 6.1.0

     Physical Memory: 4,294,967,295 / 4,294,967,295

     Virtual Memory: 2,147,352,576 / 1,044,283,392

     Screen: 1920 by 1080

     Colors: 4294967296

Insert into an Always Encrypted Table with master key in AZURE KEY VAULT is not working with ODBC Driver 17 for SQL Server

$
0
0

  I am trying to insert data into a table which is Column Encrypted using ODBC Driver 17 for SQL Server with column master key in AZURE KEY VAULT. When I try the same using SQL SERVER MANAGEMENT STUDIO it works fine. SSMS asks me my azure credentials and it inserts values into the table. I could do this without any errors when the CMK was created using windows certificate store. I exported the same certificate to azure key vault.

The below link shows that Azure Key vault with AD authentication can be used using the ODBC connection options.

https://docs.microsoft.com/en-us/sql/connect/odbc/using-always-encrypted-with-the-odbc-driver?view=sql-server-2017.

 I get the below error trying to insert and get no rows when retrieving using the odbc driver with KeyStore.Authentication as KeyVaultPassword . However KeyVaultClientSecret  auth method works  . Am I missing something here or is this an issue with the driver .

Connection String : 

"DSN=SQLSERVERNativeAE;Database=test_usr;ColumnEncryption=Enabled;KeyStoreAuthentication=KeyVaultPassword;KeyStorePrincipalId=<my mail id>;KeyStoreSecret=<my password>".

Insert into Customers (CustName, SSN, Age) values (?, ?, 10)


       SQLSTATE = CE275
       NATIVE ERROR = 0
       MSG = [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Error requesting access token, HTTP status 400, expected 200

       SQLSTATE = CE275
       NATIVE ERROR = 0
       MSG = [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Error requesting access token, HTTP status 41360, expected 200

       SQLSTATE = CE258
       NATIVE ERROR = 0
       MSG = [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Error retrieving key information for https://aesveeramakeyvault.vault.azure.net:443/keys/AEWCSPFX/35241fa9559c4e04a5e04ae21a123e0f

       SQLSTATE = CE202
       NATIVE ERROR = 0
       MSG = [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The keystore provider AZURE_KEY_VAULT failed to decrypt the ECEK https://aesveeramakeyvault.vault.azure.net:443/keys/AEWCSPFX/35241fa9559c4e04a5e04ae21a123e0f with RSA_OAEP.

CREATE TABLE [dbo].[Customers](
[CustName] [nvarchar](60) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [CEK_Auto1], ENCRYPTION_TYPE = Randomized, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256') NULL,
[SSN] [varchar](12) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [CEK_Auto1], ENCRYPTION_TYPE = Deterministic, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256') NULL,
[Age] [int] NULL
) ON [PRIMARY]

CREATE COLUMN MASTER KEY [CMK_Auto1]
WITH
(
KEY_STORE_PROVIDER_NAME = N'AZURE_KEY_VAULT',
KEY_PATH = N'https://aesveeramakeyvault.vault.azure.net:443/keys/AEWCSPFX/35241fa9559c4e04a5e04ae21a123e0f'
)

CREATE COLUMN ENCRYPTION KEY [CEK_Auto1]
WITH VALUES
(
COLUMN_MASTER_KEY = [CMK_Auto1],
ALGORITHM = 'RSA_OAEP',
ENCRYPTED_VALUE = 0x016E000001630075007200720065006E00740075007300650072002F006D0079002F003000650066003400360038003400300063006300610039003700320063006200380032003400390062003200660033003900610039003200300063006600640033003700630061003800310036006300332CAAB1F90FEF11C204297F156833E3E1E4462F03E82C1EABCD717CF3E15C3D1F36FF71AEFFCCAF0C47762E21FD1537E3F65E28F311679FE4E27778F7C19958693D931007F2656DBDA7C37BF352979637CA50F3EB682F69366353F9FA2D0EC906F023784261E8C285A02A034A5B3E189939BE1F7F3D46B0BDD0437A4A1340DB93CF55D6493020CAFF9C3FD9BCFBE8CA466FEAF5C88D949200CC815CC2519E9ECB77FEA7FEB1F7644B52AF424E43D670DC3C7EB0C55DE358489AD30C7EF52CA12C606A0C149052D1085C029EDA7150DF2559CC92A3502ED094AD94C992AE3B00A97B935294F6A68C8A3A79692F8420E369C2AA90BA5C2100288136CAB0620241AAC931F67DD0441E57F3340B5B0D2F8E3668DBBFADC3C01AEFB714C27B37DBDA51F0F7E5EDA65758D172F7B01F87946FEBCAD92D9F55A0A8A0975DAD4F95F1BE9E95B40391E73C8DCB3E45BEF13E767AA240F69AE30A00696584570BB66D8261C81DA401C177513FC55CE137504DCB49561AD5623A55C3166CD8EA8812F0E1B9EB72D456705EC1A32751DA0DF894B4861C001845D0E9D8FBB5E0ED80F6FE95CC44E3571239BC16442EEDFE8F6334F2078677B087742A35C784CEC07E77C5EFACF635E6424C97DAC42363C4445DC1DFDEA9DB46CFCDB44FE611F2BFF54A7DBBD0ACE1F925C73C9F53A90E813B220FFE2491809A3D8A7B90E590CC9D83884CC07B
)




table system not generated in *.sql sql server managment 2012

$
0
0

Hello ,
I want generate a script sql  from sql server managment 2012 to import in sql server managment 2008 , but a have problem with table system not appeared in file sql, other tables are exported .

Solution please

Slow or failing connections on Linux with the ODBC Driver 17 for SQL Server

$
0
0

We are using:

SUSE Linux Enterprise Server 12 (x86_64)
VERSION = 12
PATCHLEVEL = 4

unixODBC 2.3.7 and libmsodbcsql-17.4.so.2.1

The connection is being made to SQL Server 13.00.5101.09 and also 11.00.7462.06

We intermittently get this error:

C ERROR: -1 in function SQLConnectWithRetry (SQLConnectWithRetry) [line 3226]
C (99) [HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired
C ERROR: -1 in function SQLConnectWithRetry (SQLConnectWithRetry) [line 3226]
C (258) [08001] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x102
C ERROR: -1 in function SQLConnectWithRetry (SQLConnectWithRetry) [line 3226]
C (258) [08001] [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
C Connection 1 failed using Driver=ODBC Driver 17 for SQL

When we increase the ODBC timeout to 120 seconds, the connection works, but it takes a long time to connect.

A wireshark trace seems to indicate that there is port re-use:

 TCP 74 [TCP Retransmission] 40425 → 6201 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=1500166724 TSecr=0 WS=128

 [TCP Port numbers reused] 40425 → 6201 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=1500165693 TSecr=0 WS=128

..

TCP 74 [TCP Retransmission] 40425 → 6201 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=1500168740 TSecr=0 WS=128

ICMP 98 Echo (ping) request id=0x25b6, seq=180/46080, ttl=64 (no response found!)

We tried changing /proc/sys/net/ipv4/ip_local_port_range
from 9000 65499 to 10000 15000 and there was significant improvement, but the problem is still there.

We are using <Servername>\<Instance>,<port> to connect.

Does anyone have an idea why there is this delay in connecting to the server?

Thanks,

Gudmundur


Gudmundur Karlsson



SQL Server syntax of the query

$
0
0

Can someone help me with the SQL Server syntax for the below query.

CREATE OR replace PROCEDURE Item_reco_recordset (p_depositid IN NUMBER, 
                                                 p_b1        IN NUMBER, 
                                                 p_itemset   OUT SYS_REFCURSOR) 
AS 
BEGIN 
    OPEN p_itemset FOR 
      SELECT * 
      FROM   pcwitem 
      WHERE  deposittransid = p_depositid 
             AND ( ( Bitand(recostatecode, 1) > 0 
                     AND Bitand(recostatecode, 5) != 0 ) 
                    OR ( Bitand(recostatecode, 2) > 0 
                         AND Bitand(recostatecode, 6) != 0 ) 
                    OR ( p_b1 = 1 
                         AND Bitand(recostatecode, 3) > 0 
                         AND Bitand(recostatecode, 7) != 0 ) 
                    OR ( Bitand(recostatecode, 4) > 0 
                         AND Bitand(recostatecode, 8) != 0 ) 
                    OR ( Bitand(recostatecode, 9) > 0 
                         AND Bitand(recostatecode, 10) != 0 ) 
                    OR ( Bitand(recostatecode, 11) > 0 
                         AND Bitand(recostatecode, 15) != 0 ) 
                    OR ( Bitand(recostatecode, 12) > 0 ) 
                    OR ( Bitand(recostatecode, 16) > 0 
                         AND Bitand(recostatecode, 14) != 0 ) 
                    OR ( Bitand(recostatecode, 18) > 0 ) 
                    OR ( Bitand(recostatecode, 19) > 0 
                         AND Bitand(recostatecode, 20) != 0 ) 
                    OR ( Bitand(recostatecode, 21) > 0 ) 
                    OR ( Bitand(recostatecode, 22) > 0 ) 
                    OR ( Bitand(recostatecode, 23) > 0 
                         AND Bitand(recostatecode, 24) != 0 ) 
                    OR ( Bitand(recostatecode, 25) > 0 
                         AND Bitand(recostatecode, 29) != 0 ) 
                    OR ( Bitand(recostatecode, 26) > 0 ) 
                    OR ( Bitand(recostatecode, 28) > 0 ) 
                    OR ( Bitand(recostatecode, 31) > 0 ) 
                    OR ( Bitand(recostatecode, 32) > 0 
                         AND Bitand(recostatecode, 61) != 0 ) 
                    OR ( Bitand(recostatecode, 39) > 0 ) 
                    OR ( Bitand(recostatecode, 40) > 0 
                         AND Bitand(recostatecode, 64) != 0 ) 
                    OR ( Bitand(recostatecode, 48) > 0 ) 
                    OR ( Bitand(recostatecode, 51) > 0 ) 
                    OR ( Bitand(recostatecode, 53) > 0 
                         AND Bitand(recostatecode, 54) != 0 ) 
                    OR ( Bitand(recostatecode, 57) > 0 
                         AND Bitand(recostatecode, 58) != 0 ) ); 
END item_reco_recordset; 


Kenny ShareNlearn

Cannot connect to SQL Server 2019 using new MSOLEDBSQL

$
0
0

I am converting my application to use MSOLEDBSQL from SQL Native Client 11.0

I have changed my connection string from "Driver={SQL Native Client 11.0}" to "Provider=MSOLEDBSQL" along with UID,PWD,Server,Database parameters.

But I could not able to connect to the Database and getting "Dialog Failed "error message.

I have downloaded and installed https://docs.microsoft.com/en-us/sql/connect/oledb/download-oledb-driver-for-sql-server?view=sql-server-ver15 and could see the binaries in system32 folder

As per NOTE registry settings will be done as part of installation.

All appropriate registry settings for the OLE DB Driver for SQL Server are made as part of the installation process.
Appreciate if anyone could help in fixing this issue. Thanks in Advance.

Why Hidden Columns are shown via ODBC?

$
0
0

I am using temporal tables

https://docs.microsoft.com/en-us/sql/relational-databases/tables/temporal-tables?view=sql-server-ver15

with hidden columns

the hidden columns were NOT SHOWN with select * from tableXYZ

the hidden columns were NOT SHOWN with ADO

but they were shown with ODBC Driver 17 for MSSQL.

Is this a bug?

In my case I found a workaround but it costs me 4h time.


[ODBC DSN 64 B]

$
0
0

Hello,

How can i create a DSN 64 B to connect Access Database 2010/365 (64 B) ?

With 32 B , i use SQLConfigDataSource. But it doesn't work with application 64 B.

Is there a new method ?

I work with

- Windows 10 64 B

- Application 64 B

- Access Database 2010/365 64 B

Thank you

Goodbye

Cyril

SQLFetch seems to be working synchronously, although asynchronous notifications are enabled on the sql statement handle

$
0
0

Hi.

In our c++ Windows service we use ODBC driver 17 for Sql Server in asynchronous mode and heavily rely on it since we do our Sql calls from tasks running in Windows thread pool.

Most of the time this works very fast since we don't have any synchronous waits in our thread pool tasks.

But recently, we started having long execution times when calling stored procedures returning large number of columns (about 80, mostly short strings and numeric). After some tracing and debugging I found out that a call to SqlFetch causes delays.

We have the problem that when SqlFetch returns SQL_SUCCESS, i.e. executes synchronously, it takes more that 500 milliseconds, and that slows down the whole system. In case SqlFetch returns SQL_STILL_EXECUTING, i.e. executes asynchronously, it takes less than 1 ms.

Here is the code sample that I used to time the execution:

bool read_async() {
    auto watch = Stopwatch::StartNew();

    auto rc = SQLFetch(handle());

    auto elapsed = watch.ElapsedMilliseconds();

    //...

    if (SQL_SUCCEEDED(rc)) {
        if (elapsed > 500) {
            printf("%d: %lld\n", rc, elapsed);
        }
        return true;
    }
    if (rc == SQL_STILL_EXECUTING) {
        printf("%d: %lld\n", rc, elapsed);
        //....
    }
    //....

    return false;
}

Here is the output of the printf statements (0 is for SQL_SUCCES, 2 is for SQL_STILL_EXECUTING). In total there were about 500 rows returned from database and only once it returned asynchronously and all other times it returned synchronously with about 50 calls lasting more that 500 milliseconds.

0: 512
0: 517
0: 508
2: 0
0: 506
0: 501
0: 512
0: 640
0: 615
0: 645

.....

......

I would expect that in case SQLFetch returns SQL_SUCCESS, records are already available and it will return instantly.

Is there a way to eliminate these long synchronous executions?

Thanks,

Dragan Mihajlović


Polybase unable to place a WHERE condition on XLSX destination.

$
0
0

The WHERE condition in my TSQL query is not returning any rows, from SQL 2019 polybase to .XLSX file 

use prlobo
create master key encryption by password = 'Polybase2CSV';
    create external data source myODBCxlsx with
    (
        LOCATION = 'odbc://localhost',
        CONNECTION_OPTIONS = 'Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}; DBQ=F:\PolybaseSourceData\CustomerData.xlsx'
    );
create external table CustomerData(
CUSTOMERID FLOAT(53),
CUSTOMERNAME Nvarchar(255),
DEPARTMENT Nvarchar(255)
) with (
LOCATION='[sheet1$]',
DATA_SOURCE=myODBCxlsx
);

This query works: 
select * from customerData

However this doesn't: 
select * from customerData where customername = 'Steve'

Excel cell formatting while exporting data from sql server to Excel

$
0
0

Hi,

I am exporting data from sql server 2008 to excel using

Declare @sqlquery nvarchar(max)

SET @sqlquery='INSERT INTO OPENROWSET(''Microsoft.ACE.OLEDB.12.0'','''+'Excel 12.0;Database='+@filepath +';' + ''' ,

  ''SELECT * FROM [Sheet1$]'') ' + @query

EXEC sp_executesql @sqlquery
 
@filepath is where the file is kept with headers on which the sql server writes.

Now when I export the file.There are small green arrows in cells having numbers saying "The  number in the cell is formatted in text or preceded by an apostrophe." How can I make sql server 2008 to post numbers in number format in excel file.

Also, the numbers which are more than 7 digits like 1888120.26 get posted as 1.88812e+006.

Please tell me how to solve these two queries.


left join

$
0
0

I have some trouble create a SELECT string with a LEFT JOIN where primary key is present 3 time.

Table1(Film) FilmID, Titel, Genre1, Genre2, Genre3, Kategori, Aargang, Censur, Billede, Tags, Placering
Table2(Genre) GenreID, GenreNavn
Table3(Censur) CensurID, CensurTXT

I need the string to pull GenreNavn from table2 for Genre1, Genre2 and Genre3

My string

SELECT f.FilmID, f.titel, g.GenreNavn, f.Aargang, c.CensurTXT, f.Billede, f.Placering FROM Film AS f LEFT JOIN Genre AS g ON f.Genre1 = g.GenreID LEFT JOIN Censur AS c ON f.Censur = c.CensurID WHERE filmid = 1

I have tried adding AND f.Genre2 = g.GenreID AND f.Genre3 = g.GenreID
and
LEFT JOIN Genre AS g ON... for both Genre 1 and 2. 

None of it works.

JSON ODBC Drivers

$
0
0

I got the SQL Server 2019 Community Edition installed on my machine.

Just wondering if there's any way I can import JSON data directly via the Tasks > Import Data wizard? and also in SSIS?

I know how to import data via OPENJSON but just curious to ask for above.

Thanks

Regards,
Ryan

Not able to execute command

$
0
0

I can't execute the query in SSMS. I always get this error: An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.

Viewing all 4164 articles
Browse latest View live


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