openrowset

Using dynamic sql in openrowset produces error

倖福魔咒の 提交于 2019-12-13 06:00:03
问题 I need to create a stored procedure that gets a path as a parameter and inserts from file into table via OPENROWSET command. After lots of searching and trying, I learned that OPENROWSET does not support parameters and thus needs to be called with dynamic SQL. That is the part that doesn't work, it shows me a strange error. It could be caused by the OPENROWSET not accepting the string parameter but - I saw many code snippets that are built similarly and users say they work. Please help me

BULK INSERT / OPENROWSET FormatFile Terminator for CSV file with , (comma) in the data

…衆ロ難τιáo~ 提交于 2019-12-13 00:18:57
问题 I've written a nice import for my million row CSV that works quite nicely (using OPENROWSET BULK (I didn't use BULK INSERT because I need to cross join with some other columns). The formatfile uses a comma as the Terminator. Here is an example of the CSV I was using to develop: Reference, Name, Street 1,Dave Smith, 1 Test Street 2,Sally SMith,1 Test Street Once I'd got it working, someone reminded me that the data itself could have a comma in it, whoops!!!! Reference, Name, Street "1","Dave

Why do I get no results when returning the results of a Stored Proc?

≡放荡痞女 提交于 2019-12-12 22:34:44
问题 In the first step of what will build up to include several temp tables and Stored Procs being called and then Unioned, I have the first baby steps (based on the answer from Philip Kelley here): IF OBJECT_ID ( 'RockBottomAmalgamated', 'P' ) IS NOT NULL DROP PROCEDURE RockBottomAmalgamated; GO CREATE PROC [dbo].[RockBottomAmalgamated] @BegDate datetime, @EndDate datetime, @SortBy varchar(20) AS CREATE TABLE #BaseCraftworksTable ( Unit varchar(25) not null ,ShortName varchar(50) ,ItemCode

SQL Server 2005 OPENROWSET insert into Excel - text to number formatting

為{幸葍}努か 提交于 2019-12-12 02:49:11
问题 So it's not a huge deal, but with Google not returning anything more recent (mostly 2007 or so) about it possibly being an Excel driver issue...I came here to ask the question as what I found as an "answer" was not acceptable without further research. My problem: Writing a dynamic OPENROWSET query clear and insert new data to send off a report to specific users - the base excel report contains some formulas in which it calculates off and sums based off the inserted data and the multiplication

Exporting data to excel from sql server is not working

二次信任 提交于 2019-12-11 16:00:09
问题 I am using the below code to export data to excel file. This is working fine when the excel file is blank. But when I update the filed to null then the insert query is executed successfully but the excel is showing blank. update openrowset('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=E:\..\.xlsx;', 'select Column1,Column2,Column3 FROM [Sheet1$]') set Column1=null,Column2=null,Column3=null insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=E:\..\.xlsx;', 'SELECT * FROM

The metadata could not be determined because every code path results in an error; see previous errors for some of these

别来无恙 提交于 2019-12-10 19:46:39
问题 I am migrating from SQL Server 2005 to SQL Server 2014 and one of the queries stopped working in SQL Server 2014: select * from openrowset ('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;',' exec [MyDatabase].[dbo].[MyTable]') I get the following error message: Msg 11529, Level 16, State 1, Procedure sp_describe_first_result_set, Line 1 The metadata could not be determined because every code path results in an error; see previous errors for some of these. Msg 4902, Level 16, State 1,

How to export SSIS to Microsoft Excel without additional software?

瘦欲@ 提交于 2019-12-06 03:05:58
问题 This question is long winded because I have been updating the question over a very long time trying to get SSIS to properly export Excel data. I managed to solve this issue, although not correctly . Aside from someone providing a correct answer, the solution listed in this question is not terrible. The only answer I found was to create a single row named range wide enough for my columns. In the named range put sample data and hide it . SSIS appends the data and reads metadata from the single

How to export SSIS to Microsoft Excel without additional software?

大城市里の小女人 提交于 2019-12-04 08:31:32
This question is long winded because I have been updating the question over a very long time trying to get SSIS to properly export Excel data. I managed to solve this issue, although not correctly . Aside from someone providing a correct answer, the solution listed in this question is not terrible. The only answer I found was to create a single row named range wide enough for my columns. In the named range put sample data and hide it . SSIS appends the data and reads metadata from the single row (that is close enough for it to drop stuff in it). The data takes the format of the hidden single

Connect to a webservice from SQL

 ̄綄美尐妖づ 提交于 2019-12-03 14:11:00
SQL Server is able to open excel sheets (xlsx), access databases (mdb) and other data streams using data providers (e.g. JET, ACE) and OPENROWSET. Are there similar facilities to extract data from a remote webservice ? Using OPENROWSET and providing it a web service driver and URL and some schema definition to translate the hierarchical nature of the webservice XML output into a table that SQL Server can query on. I'm thinking of something like: select * from OPENROWSET('WEBSERVICE.4.0.PROVIDER','http://mydomain/webservice.asmx') That's a high level question, although I know it's conceptually

INSERT INTO from two different server database

醉酒当歌 提交于 2019-12-02 22:38:15
I am trying to copy the data of testdabse.invoice table to basecampdev.invoice table. testdabse is a local database while basecampdev is in the server. My query for copying data to another table doesn't work, it says Invalid object name 'basecampdev.dbo.invoice'. I've been reading this documentation but find it hard to follow and understand. These are the information given from the server Server type: Database Engine Server name: server.database.windows.net (this is not the real name) Authentication: SQL Server Authentication Login: myusername Password: mypassword How can I connect to the