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

External tables

$
0
0

 

Is there a provision for external tables in SQL Server? (along the lines of Oracle external tables) I want to be able to keep archive backups in an external table (flat file) by say, running a script everyday that deletes rows older than 6 months from the db tables and inserts this data into the external tables. In the future, I should be able to restore this data into the original db tables.


Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2260.0' : file not found

$
0
0

One process fails with this ODBC error message:
Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2260.0' : file not found
Even though the file is clearly there.

Another process (a smaller executable, from the command line) succeeds.

The straces of a succeeding and failing process are on

https://skydrive.live.com/?cid=7351CCB20D6E0D6A&id=7351CCB20D6E0D6A%21103

File: succeeds_and_fails.zip

Why does the connect fail in one case but succeed in another?

CAL, IIS, SQL Server

$
0
0

Hi.

I have been searching the web about information regarding how licensing works when an IIS service access SQL server.

This is the scenario:

1 IIS Server running webservice.
1 SQL Server.

Multiple clients/users (Webservice calls) logging in to the website using ASP.NET forms or other autentication in open source db
ie the users are NOT logging on to the SQL Server using windows authentication or SQL authentication.
It is only the webservice that is logging on to the SQL server.

Do i need Single user CAL for each user on my website?

Since we cant get information about this we ar considering migrating to another database platform, thus we realy love SQL Server.

Can't Login into Local Database SQL Server 2014

$
0
0

I have been using SQL Server 2014 for an online SQL class. All of a sudden, I can't login. I am receiving the following message:

TITLE: Connect to Server
------------------------------

Cannot connect to CSTRAUBSCOUT\SQLEXPRESS2014.

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

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

Connecting to Oracle database hosted on cloud

$
0
0

Hi Folks,

Our payroll database is on Oracle because of the Payroll software we are using. I connect/access that oracle database using MS SQL server Linked Server option to pull data routinely, using MS SQL Job, to our Reporting Services database for reporting purposes.

Now the payroll software is upgraded to cloud base and we are being advise to use PuTTY to connect to the oracle database. Now with PuTTY, will I be able pull data into my MS SQL Reporting Services database?

Is there any other way where MS SQL Server can connect directly to the Oracle DbaaS (hosted database)  through a SSH Tunnel?

Appreciate your prompt response.

 


Marsh Narewec

Database is not visible in the object explorer but still I can connect to database

$
0
0

Hi

 While doing some security test I found one interesting item. I am not able to see the Database in the object explorer but still I can connect the database and do all operation. :) .  I did few simple work for this. I have removed the permission of the Public role to view database and then later I have given all the permission to the login/User on the database. so when this user login he is not able to see the database in the object explorer , as he has permission on the direct database so he can do all operation :). I am not sure Microsoft team has did this knowingly or its bug... 

Thanks in advance...


Regards Vikas Pathak

Windows 7 RC ODBC Access driver

$
0
0
Many apologies for posting here, but it's the nearset I can find. I am running the Windows 7 RC (x64) and need the MS Access 32-bit ODBC driver in order to connect to an in-house application. The driver doesn't appear to be shipped with Windows 7 and I cannot find anywhere to download it.

On further inspection, the 32-bit SQL Server ODBC driver appears not to ship either and I need that as well.

SQL Script for total daily transaction?

$
0
0

How to find the count of daily transactions from the SQL database?


verifying TDE or Data encryption enabled on SQL Server

$
0
0

Dear Members, 

I need a quick check to test if TDE or data encryption enabled on SQL Server. When i query any table on SQL server I can see the data is in plain text, isn't it should be encrypted ?


Tech Learner

Query a linked server via SQL Server from an ODBC client

$
0
0
Trying to figure out how to reference a Linked Server (PostgreSQL linked to SQL Server 2012 with OLEDB) from a client application.  Specifically, how to setup the client ODBC connection to SQL Server and be able to access the Linked Server).  The linked server doesn't show up as a database in ODBC configuration, so not sure if it is surfaced to an ODBC client?  I have tried both SQL Server ODBC and SQL Server Native clients to no avail, and any and all queries on this topic on the web lead exclusively to articles on how to setup a linked server that links to an ODBC source.  I'm trying to go ODBC->SQL Server->Linked Server.

Size of parameters is ignored when stored procedure is executed by Entity Framework.

$
0
0

Hi everybody,

I have the following C# code to execute stored procedure in Entity Framework:

 SqlParameter originalContact = new SqlParameter("@originalContact", SqlDbType.Decimal, 17);
            originalContact.Value = idToRemove;

            SqlParameter newContact = new SqlParameter("@newContact", SqlDbType.Decimal, 17);
            newContact.Value = idToKeep;

            SqlParameter Salespoint = new SqlParameter("@salespoint", SqlDbType.Char, 6);
            Salespoint.Value = salespoint;

            SqlParameter opCode = new SqlParameter("@operator", SqlDbType.Char, 6);
            opCode.Value = operatorCode;

            SqlParameter debug = new SqlParameter("@debug", SqlDbType.Bit);
            debug.Value = 0;

            _siriusContext.CoreContext.ExecuteStoreCommand(@"execute dbo.siriussp_DedupeContact
                 @originalContact = @originalContact,
                 @newContact = @newContact,
                 @salespoint = @salespoint,
                 @operator = @operator,
                 @debug = @debug", originalContact, newContact, Salespoint, opCode, debug);

The stored procedure has parameters defined as decimal(17,0) - matching the column's type in the table, e.g.

ALTER PROCEDURE dbo.siriussp_DedupeContact
(@originalContact decimal(17,0),
@newContact decimal(17,0),
@salespoint CHAR(6),
@operator CHAR(6),
@debug bit = 1)

However, when I check the call using SQL Server Profiler I see

exec sp_executesql N'execute dbo.siriussp_DedupeContact @originalContact = @originalContact, @newContact = @newContact, @salespoint = @salespoint, @operator = @operator, @debug = @debug',N'@originalContact decimal(9,0),

@newContact decimal(9,0),@salespoint char(6),@operator char(6),@debug bit',

@originalContact=167000001,@newContact=129000001,@salespoint='SYSMGR',@operator='ADMIN ',@debug=0


It is probably not critical, but why the explicitly stated size of the parameter is ignored in the call?

UPDATE. I'm going to try without @par=@par, just with @par syntax now.

UPDATE 2. Changing the call syntax to remove the = part didn't change anything. The size is still ignored.


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


My blog


My TechNet articles



select when NULL

$
0
0

Hello everyone,

im trying to get a select command to select all the data when i textbox parameter is empty

this is what ive got

  SelectCommand="SELECT * FROM [Table] WHERE @First_Name IS NULL OR LEN(@First_Name) < 2 OR ([First_Name] LIKE '%' + @First_Name + '%')"

<SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="First_Name" PropertyName="Text" Type="String" />
            </SelectParameters>

it works if i fill in text it work if i have less then 2 characters in the textbox but does nothing if the textbox is empty. does anyone have any ideas on what i can do??

thanks

Access Excel file (XLSX) with SQL via OLEDB

$
0
0

Hello, 

I'm executing read and write actions on an excel file via oledb. With help of a lot for posts that I read i succeeded with a penty of functions. Thanks for that!

But now I'm faceing some weird behavior and it seems I need some specific help. If some value is TRUE that in a raw of a DataTable, the value level should be incremented, otherwise it shall be set to zero.

The excel sheet has following structure.

           A               B                 C              D

1    vLocKey       DictKey        vLevel       vCounter

2         0               0                 0               0

3     1000000    1000001           0                0

4     1000001    1000002           1                2

5     1000002    1000003           2                2

6     1000003    1000004           3                1

7     1000004    1000005           4                4


The datatable "tableModified" has following columns: "GlobKey"; "Text1"; "Text2"; "sState"; "sCorrect".  The column "sCorrect" is represented by an integer value but used as boolean.

         DataTable tableModified = (DataTable)myDataSet.Tables[0].GetChanges(DataRowState.Modified);
         updateAdapter.UpdateCommand =
         new OleDbCommand("UPDATE [Tabelle2$] SET vLevel = vLevel + 1 "+ "WHERE DictKey = @DictKey", cn);

         updateAdapter.UpdateCommand.Parameters.Add("@GlobKey", OleDbType.UnsignedInt, 50, "DictKey");
         updateAdapter.UpdateCommand.Parameters.Add("@sState", OleDbType.UnsignedInt, 50, "sState");
         updateAdapter.UpdateCommand.Parameters.Add("@sCorrect", OleDbType.UnsignedInt, 50, "sCorrect");

         updateAdapter.Update(tableModified);

The SQL-Querry is working fine. Values are updated as I would expect. Unfortunately it's not yet what I need.

I tried different solution. one is to use sCorrect to "calculate" my result. For this I changed my querry as following:

         new OleDbCommand("UPDATE [Tabelle2$] SET vLevel = (vLevel * @sCorrect) + 1 "+ "WHERE DictKey = @DictKey", cn);

In fact I was kind of supprised that this really is executed. Just the result on the excel sheet is not what I want. In stead of incrementing Cells C4 and C5 the value1000004 is writen to cell C2.

In another try I worked with the switch function.

         new OleDbCommand("UPDATE [Tabelle2$] SET vLevel = SWITCH(@sCorrect = 1, 1, @sCorrect = 0, 0) "+ "WHERE DictKey = @DictKey", cn);

But also this was not the solution for my problem. This time the value of C2 is deleted instead of updating C4 and C5.

If I use fixed values instead of the parameter @sCorrect the behavior is as I would expect.

Hope that anybody can help me with this. Thanks in advance for your help.


SQL Server 2014 - error OLE DB provider "MSDASQL" for linked server "(null)" trying to load CSV file

$
0
0

What does a linked server have to do with this issue?


select 
*
from openrowset('MSDASQL'
,'Driver={Microsoft Access Text Driver (*.txt, *.csv)}'
,'select * from t:\baseball\"AllstarFull".CSV')

Error Below:

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Text Driver] Your network access was interrupted. To continue, close the database, and then open it again.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)". 

Database restore script with changing file name daily - SQL Server 2012 R2

$
0
0

Hello,

 We currently download a copy of our database from a vendor application on a nightly basis. every day the filename changes. I wanted to know what the best way to script the restore nightly would be? Should I change the file names to db1.bak and db2.bak and then restore?

Thanks,

Derek


Re: OLE DB provider "DB2OLEDB" for linked server "" returned message "An internal network library error has occurred. A network level conversational protocol error has occurred."

$
0
0

Hi All,

I am trying to setup Linked server to IBM-DB2 using Microsoft OLEDB Provider for DB2 V4.0 on Microsoft SQL SERVER 2012. (x64).  It throws me below error.

EXEC sp_addlinkedserver
@server = 'ServerName',
@srvproduct = 'Microsoft OLE DB Provider for DB2',
@catalog = 'DBName',
@provider = 'DB2OLEDB',
@provstr= 'Initial Catalog=DBName;Data Source=DBName;HostCCSID=1252;Network Address=Servername;Network Port=50000;Package Collection=MSUR001;Default Schema=;'
GO
EXEC sp_addlinkedsrvlogin 'servername', false, NULL, 'username', 'password'
GO
GO
sp_testlinkedserver Servername;
GO

Error:

OLE DB provider "DB2OLEDB" for linked server "" returned message "An internal network library error has occurred. A network level conversational protocol error has occurred.".
Msg 7303, Level 16, State 1, Procedure sp_testlinkedserver, Line 1
Cannot initialize the data source object of OLE DB provider "DB2OLEDB" for linked server "".

Thanks,

Balwant.


Failure in Life is failure to try... PGDCA-98(South Gujarat University),MCSA (SQL 2012) , MCTS (SQL Server 2005) http://blog.vspatel.co.uk/

Mechanisms to access SQL Server behind firewall using JDBC driver

$
0
0
Does SQL Server JDBC driver facilitate accessing SQL Server behind a firewall in any way like some Type 3 JDBC drivers do? I'm trying to understand options incase a customer is unwilling to open up the DB port or allow VPN. For ex. do we suggest a solution along the line of a connection manager proxying connections through firewall instead ofdirectly opening up any port that the database listener is using? or try HTTP tunneling over SSH?

Error when using a linked server to query AD from SQL Server 2012

$
0
0

Hi, I am getting the following error when I try to query AD from one of our SQL servers:

Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "ADSDSOObject" for linked server "ADSI".

The query is now about as simple as I can make it only retrieving one record from a single OU and the same error occurs. 

A few years ago I made a change to AD MaxPage Size to overcome the 1000 record limit and that is still in place and working. But from this one server I continually get the same error.

Can anyone offer an explanation other than:

  • TOP 901 record limits
  • Selecting "Allow Inprocess" against the ADsDSOObject
  • Changing the MaxPageSize setting.

I am domain admin and the error still occurs with the "connection made using the login's current security context" so I don't think it relates to the remote login, otherwise I have run out of ideas.

My query is now cut down to this:

Select * from OpenQuery ( 
  ADSI,  
  'SELECT displayname, samaccountname, mail, employeeid
  FROM  ''LDAP://<Domain path>
  WHERE objectClass =  ''User'' and objectcategory = ''person'' and samaccountname = ''username''
  ')

I created the linked server from a script created on another SQL server on the same network where this same ADSI query works fine. 

The domain path I am using is to a single OU containing a dozen accounts.

Any suggestions are appreciated.

Excel VBA - Calling Stored Procedure Timeout after x executions

$
0
0

Can someone explain me this behaviour?

We are executing a stored procedure calling it from Excel VBA and placing the results in a pivot table. We use this code:

Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
Set cmd = New ADODB.Command

connectionstring = "Provider=SQLOLEDB.1;Password=***;User ID=***;Initial Catalog=***;Data Source=***"
cnn.Open connectionstring

With cmd
    .ActiveConnection = cnn
    .CommandType = adCmdText
    .commandText = "EXEC spTest '" xxx "', '" & xxx "';"
End With

Set rst = cmd.Execute

The stored procedure: contains 200 lines of code that executes in 1 sec with the correct result.

The problem occurs after x time of successfull executions that we get a timeout error. The only way I can slove this problem, is to comment out 75% of the stored procedure and execute it again from Excel. Next we comment out 50% of the stored procedure and execute it again. Next 25% and the last run we execute the full stored procedure again and now there is no more timeout error coming out.

When I call it now it returns the results in about 3 seconds in a pivot table in Excel. This is not the first time I ran into this problem.

Does anyone else ever had this issue? What can I do about it? What causes this behaviour?

Thx!

Inserting into PostgreSQL using OpenQuery

$
0
0

I'm trying to insert data into a PostgreSQL server using the Link Server, I get this error


Msg 7356, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "POSTGRESQL" supplied inconsistent metadata for a column. The column "status" (compile-time ordinal 4) of object "Select * From Data" was reported to have a "DBCOLUMNFLAGS_ISNULLABLE" of 32 at compile time and 0 at run time.


I have try Collation changes as as some blogs suggested, but no go.


Anyone has any ideas?



Viewing all 4164 articles
Browse latest View live


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