openrowset

how to use openrowset to execute a stored procedure with parameters

自古美人都是妖i 提交于 2019-12-23 16:53:35
问题 I'm creating a stored procedure which gets some parameters and in turn these parameters are sent to another stored procedure which I'm calling from openrowset but I'm getting some syntax errors. CREATE PROCEDURE UpdatePrevFYConfigData -- Add the parameters for the stored procedure here @startDate datetime, @endDate datetime, @productGroup varchar(8000) = 'All', @projectType varchar(500) = 'All', @businessUnit nvarchar(50) = 'All', @developmentLocation nvarchar(100) = 'All' AS BEGIN -- SET

INSERT INTO from two different server database

与世无争的帅哥 提交于 2019-12-20 09:53:55
问题 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)

pass dynamic file path of excel to “OPENROWSET”

♀尐吖头ヾ 提交于 2019-12-20 07:13:06
问题 I want pass dynamic URL of excel to "OPENROWSET". NOTE - I am passing returned result of excel file to cursor. I want to pass file path to "@excelpath", I have tried many ways but its giving syntax error. ALTER procedure [dbo].[import_excel] ( @excelpath as nvarchar(max) ) as begin set nocount on DECLARE insert_cursor CURSOR FOR select * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\memberdata.xlsx', [Sheet1$]) OPEN insert_cursor; FETCH NEXT FROM insert_cursor INTO @id

Use Parameter In OPENROWSET Sql Server

强颜欢笑 提交于 2019-12-20 04:29:06
问题 I am creating an stored procedure in which I am calling an another stored procedure(This procedure is returned lot of columns and I want only one column value So I can't create temp table to store values) using OPENROWSET . When I am use following then it's alright declare @AgencyID int=15,@PatientID int=3701 SELECT a.PrimaryInsuredName FROM OPENROWSET('SQLNCLI', 'Server=ServerName;Database=DbName;Trusted_Connection=yes', 'exec USP_Billing_GetPatientWithInsurence 3701,15') AS a; It's working

t-sql, sql table inner join spreadsheet

落花浮王杯 提交于 2019-12-20 02:01:11
问题 I have a table (AmenityData) of data and a column of this table contains postalsectors e.g. E14 7 I also have an Excel spreadsheet with a list of postal districts e.g. E14 I need to get all the data out of the AmenityData table where the postal districts are LIKE the postal sectors e.g. WHERE [PostalDistricts] + '%' LIKE [PostalSector]. The code i'm using at the moment is not coming up with an error but just returning nothing and i know that there should be plenty of results returned: SELECT

OPENROWSET with Excel file

有些话、适合烂在心里 提交于 2019-12-19 04:50:46
问题 I want to execute simple statement: SELECT * FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]') And suddenly I get this message today morning: Msg 7308, Level 16, State 1, Line 1 OLE DB provider 'MICROSOFT.JET.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. It was working till today morning! Here is my server specs: Windows 2008 R2 64 bit SQL Server 2008 64 bit I've

T-SQL: issue with string concat

陌路散爱 提交于 2019-12-18 07:38:30
问题 I have a set of audio files with names GreenLine1.mp3, GreenLine2.mp3 e.t.c. I'm going to write them into a table as BLOB (I use MS SQL Server'08), here's my sql request: DECLARE @aud AS VARBINARY(MAX) DECLARE @num AS INT -- Load the audio data SET @num=1 WHILE (@num<38) BEGIN; SELECT @aud = CAST(bulkcolumn AS VARBINARY(MAX)) FROM OPENROWSET( BULK 'C:\Users\Ilya\folder\GreenLine' + CAST(@num AS VARCHAR) + '.mp3', SINGLE_BLOB ) AS x -- Insert the data to the table INSERT INTO Mb2.dbo.Audios

T-SQL: issue with string concat

本小妞迷上赌 提交于 2019-12-18 07:37:39
问题 I have a set of audio files with names GreenLine1.mp3, GreenLine2.mp3 e.t.c. I'm going to write them into a table as BLOB (I use MS SQL Server'08), here's my sql request: DECLARE @aud AS VARBINARY(MAX) DECLARE @num AS INT -- Load the audio data SET @num=1 WHILE (@num<38) BEGIN; SELECT @aud = CAST(bulkcolumn AS VARBINARY(MAX)) FROM OPENROWSET( BULK 'C:\Users\Ilya\folder\GreenLine' + CAST(@num AS VARCHAR) + '.mp3', SINGLE_BLOB ) AS x -- Insert the data to the table INSERT INTO Mb2.dbo.Audios

openrowset for excel: can we skip several rows?

血红的双手。 提交于 2019-12-18 05:45:06
问题 I will use the following sql to read data from excel, but sometimes I need to skip first several rows. e.g the real data begins from line 5, so I need to skip the first 4 rows, is that doable? SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;HDR=YES;Database=c:\daniel\test.xls', 'SELECT * FROM [sheet1$]'); 回答1: Use a range [sheet1$A5:Z] instead of the entire sheet [sheet1$] SELECT * FROM OPENROWSET( 'Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;HDR=YES;Database=c:\daniel\test.xls',

Cannot initialize the data source object of OLE DB provider “MSDASQL” for linked server “(null)”

≡放荡痞女 提交于 2019-12-17 18:13:22
问题 Having an interesting issue. I'm reading from an excel file on a server via an OpenRowset in Sql2005. I've run the query a number of times without any problems. I've just gone out for a quick meeting and suddenly I get the error "Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)"" I've made sure the files are not in use on the server and even deleted them and recopied them over onto the server and still I'm getting the same error. UPDATE: This