OPENROWSET Parms'

Mar 14, 2008

Hi

I've got the following code that uses OPENROWSET but I need to paramaterise the filepaths and its not working:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

BEGIN

declare @dataareaid as varchar(3)
declare @configpath as varchar(100)
declare @configfile as varchar(100)
declare @configformatfile as varchar(100)


set @configfile = 'C:ConfigFileConfigFileMot.txt'
set @configformatfile = 'C:ConfigFileConfigFormatFile.txt'

print @dataareaid
print @configpath
print @configfile
print @configformatfile

set @dataareaid = (SELECT dataareaid
FROM OPENROWSET( BULK @configfile , FORMATFILE = @configformatfile
) AS a)


select *
FROM AX.[P2].dbo.Dimensions Dim
WHEREDim.dataareaid = @dataareaid

END

View 3 Replies


ADVERTISEMENT

Using Parms With IN Clause

May 12, 2006

Is there a way to use a parm in the 'IN' of a where clause?Example (integerValue is an int datatype):declare @list as varchar(max)set @list = '1, 2, 3, 4'select *from table1where integerValue IN ( @list )

View 4 Replies View Related

Stored Procedure Parms Disappearing

Jun 4, 2007

I'm executing a stored procedure from an Execute SQL Task in my SSIS package. The procedure takes two input variables and creates and executes an SQL statement based on those variables. I don't have it set to return anything.



When I run the package in debug mode on my desktop, it runs just fine.



However, when I save it to the RDBMS and execute it as a step in a job, the stored procedure errors out because it doesn't receive the input parameters. If I replace the ? in the statement with the value I know the parm should have, it executes just fine. The parms are mapped to the 0 (and, where applicable, 1) input parms.



As an aside, the package variable supplying the value is a byte value. However, in the parm mapping for the step, I define it as varchar because that's what the stored procedure is expecting. Could this be goofing me up?

View 6 Replies View Related

Passing Parms With No Values To A Stored Procedure

Feb 28, 2008

I'm want to pass empty parm value to a stored procedure. I'm new at this stuff and not sure how to do this. To make it work I can put values in parms and it works great. I don't want to populate some of the fields in the table with values. The fields are cnty,dist,beat,convertedkey. Anyone know how I can get it done? Code below. Thanks for your help!

int shift = Convert.ToInt16(dr.Cells[1].Value.ToString());

int prior = Convert.ToInt16(dr.Cells[2].Value.ToString());

string lname = Convert.ToString(dr.Cells[3].Value.ToString());

string fname = Convert.ToString(dr.Cells[4].Value.ToString());

string unit = Convert.ToString(dr.Cells[5].Value.ToString());

string handle = Convert.ToString(dr.Cells.Value.ToString());

int badge = Convert.ToInt16(dr.Cells[7].Value.ToString());

string cnty = Convert.ToString('1');

string dist = Convert.ToString('1');

int beat = Convert.ToInt16(1);

int convertedkey = Convert.ToInt16(1);

char action = 'I';

char assign = 'Y';

var db = new dpoffassignedDataContext();

var q = db.SP_DpAssignAllOfficers(action, convertedkey, shift, prior, lname, fname, unit, handle, cnty, dist, beat, badge, assign);





Stored procedure below;

ALTER PROCEDURE SP_DpAssignAllOfficers

(

@action nvarchar(1),

@int_id int,

@shift int,

@prior int,

@lname nvarchar(20),

@fname nvarchar(20),

@unit nvarchar(5),

@handle nvarchar(10),

@cnty nvarchar(10),

@dist nvarchar(10),

@beat int,

@badge int,

@assign char



)

AS

INSERT

INTO dpofficers(dpo_prior,dpo_lname,dpo_fname,dpo_unit,dpo_handle,dpo_cnty,dpo_dist,dpo_beat,dpo_badge,dpo_shift)

VALUES (@prior,@lname,@fname,@unit,@handle,@cnty,@dist,@beat,@badge,@shift)

View 6 Replies View Related

OLEDB Versus ADO.NET For UPDATE Statement Using Parms

Jun 14, 2006

In SSIS, I have an Execute SQL Task that runs a direct SQL statement as follows to update an MS/SQL database table:

Update auditTable SET PackageName  =  @pkgname

In the parameters mapping, @pkgname is mapped to the System variable System::PackageName (as input).

This task runs fine if I use ADO.NET as the data source without any error.

But if I use OLEDB as the source it fails miserably and requires that the @pkgname variable be defined (as if it's a user variable, when in fact it was intended as a parm for the update statement only).

Any idea why that happens?

Thanks

Tommy

View 7 Replies View Related

Problem In Calling A Stored Proc With OUTPUT Parms

Sep 26, 2000

I have a problem in calling a procedure.
It has two input parameters and seven(7) output parms.

When I run it this way:

exec usp_List_Relationship_Users @relationship_id = 1851 ,
@status = 'Channel Member',
@cust_idOUTPUT,
@user_login_id OUTPUT,
@username OUTPUT,
@password OUTPUT,
@status_id OUTPUT,
@sdesc OUTPUT,
@administrator OUTPUT

I get this error:
Server: Msg 119, Level 15, State 1, Line 10
Must pass parameter number 3 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'.

But when I run it this way :
exec usp_List_Relationship_Users 1851 ,
'Channel Member',
@cust_idOUTPUT,
@user_login_id OUTPUT,
@username OUTPUT,
@password OUTPUT,
@status_id OUTPUT,
@sdesc OUTPUT,
@administrator OUTPUT

I get the expected results. Why should I omit the name of the name of the input parameters? I don't know why I am getting this error if don't run by ommitting the name of the input params.

Any help regarding this matter is greatlt appreciated.
You can assume that all the variables are declared prior to executing the stored procedure.

Regards
Sushruth Nanduri.

View 3 Replies View Related

How To Pass Command Line Parms To The Execute Package Task

Oct 2, 2006

I have a ForEachLoop parent pkg that reads thru the file system of dtsx to be executed.

I would like to pass CLI parms to the command itself (dtexec). I'm not looking at passing values to the child pkgs but rather additional command line values such as:

/CONFIGFILE "C:myconfig.dtsConfig.



In my expression builder for the PackageName I added the additional string but during the execution, the reference to my dtsconfig is ignored without any errors and the child pkg runs using the default values provided at design time.

@[User::PackageToRun] + " /CONFIGFILE C:\myconfig.dtsConfig ".



How does one add additional CL values during the runtime for Execute Package Task?



Thanks,

Anatole

View 3 Replies View Related

Openrowset

Nov 20, 2002

How come when I run the script:
select * from openrowset ('MSDASQL', 'Driver=Microsoft Excel Driver (*.xls);DBQ=\inawwwpro01d$atrUploadACK102.xls' , 'select * from [sheet1$]') from Server A I get a RESULT, and when I run from Server B I get the following error:
Ad hoc access to OLE DB provider 'MSDASQL' has been denied. You must access this provider through a linked server.
Both servers are using IDENTICAL SQL Logins.
Both servers are SQL 2000 SP2.

When I run the script on Server B logged in as SA, then I get a Result!!!

View 4 Replies View Related

OpenRowset

Mar 7, 2005

I can successfully retreive data using:

Declare @Path varchar(100)
Declare @CommandString varchar(100)
Set @Path = ''
Set @CommandString = 'Select * from [myTable.csv]'

EXEC('SELECT *
from OpenRowset(''MSDASQL'', ''Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=\myServermySharedb' + @Path + ';'',''' + @CommandString + ''')')

Does anyone know an easy method to get column names into a table using OpenRowset :confused:

View 1 Replies View Related

Openrowset

Jan 14, 2008

how can i use openrowset. my aim is to develop a import and export data from diff. server . i am using vb.net 2003 , sql sever 2000.
when i am running
openroeset function with window or server authontication it is showing
'OLE DB provider 'SQLOLEDB' reported an error. The provider did not give any information about the error.


anybuddy help me , pls. tell me the right solution.

View 3 Replies View Related

OPENROWSET

Aug 21, 2007

Hi!
I decided to use OPENROWSET for importing data from an excel file into a sql table.When I import the data,I have a problem:

-not all the data is imported to my sql table
-some values in the sql table are different from the ones in the excel file
For example,a value that in the excel file is:87878787 will be in the SQL table:8.78788e+007.

Can somebody pls tell me what's the problem

View 1 Replies View Related

OpenRowSet BUG?

Jul 23, 2005

Hi Folks,I am trying to load data from a table in MS Access to SQL Server 2000using T-SQL OPENROWSET. When I select data from the remote database (MSAccess) using SQL Query analyzer, the columns do NOT appear in the sameorder as seen in Access directly.For e.g. if Access table has columns Cy, Cx, Cz the output in Queryanalyzer appears as Cx, Cy, Cz. It appears to arrange the fieldsalphabetically. This causes problems when I do a 'insert into select *from' as the field definitions do not agree.Is this a bug or is there a setting in Access/SQL which I am missing?Also, please let me know if there is a workaround for this issue.Thanks in advance!Bhaskar

View 3 Replies View Related

OPENROWSET Only Returns First Row

Oct 15, 2014

I've got some text files that I need to read and make some calculations, before inserting data into a table.

When I use:

Code:
select BulkColumn as txt from openrowset(BULK 'c:Tempdata35.txt', SINGLE_NCLOB) as text

It only retrieves the first row. How can I select all the lines in the file?

View 1 Replies View Related

OPENROWSET Error

Mar 25, 2004

I am trying to use OPENROWSET in SQL Server to connect to my Access database, but I keep getting the following error:

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: The Microsoft Jet database engine cannot open the file 'X:SetupDatabaseKDB_X2.mdb'. It is already opened exclusively by another user, or you need permission to view its data.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: ].

I have checked the database, it is not in use, and there is no password set on the database that would prevent me from getting access to it. Any ideas? Here's the syntax I'm using:

SELECT *
FROM OpenRowset('Microsoft.Jet.OLEDB.4.0',
'X:SetupDatabaseKDB_X2.mdb';'Admin';'', subPSEL_PList))

View 3 Replies View Related

XML RELATED OPENROWSET

Jun 20, 2008

select @xml = bulkcolumn from openrowset(bulk 'C:Documents and
SettingsKasiDesktopewsrss.xml' , single_blob) as channel



here after bulk instead of giving path, we have to give parameter so that the paramter takes the value from the table.

the tables contains paths of xml files

View 2 Replies View Related

OPENROWSET And EXCEL

Nov 7, 2006

I having an excel file called TEST.XLS (in c: drive) which has 3 columns (c0,c1,c2) & 8 rows
c0 c1 c2
1 a A
2 b B
3 c C
4 d D
5 e E
6 f F
7 g G
8 h H

In sql server i have one table called TEST which has three columns
c0 char(10)
c1 char(10)
c2 char(10)


when i runnig the following query

select *
into TEST from openrowset('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:TEST.xls;HDR=YES',
'select * from [Sheet1$]')



i am getting error like this

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IColumnsInfo::GetColumnsInfo returned 0x80004005: ].

Version : Sql server 2000 & Excel 2002

Anybody having any idea why this error occuring?
thanks in advance...
Philkos

View 2 Replies View Related

OPENROWSET To Excel

Jan 14, 2007

Hi Anyone I am new member and happy to be here.

I am having trouble exporting the correct data from sql server to an excel spreadsheet using 'OPENROWSET'

The problem is that although the data from my sql table is say :
'a',1,2,3 , the excel spreadsheet sees the data as :
'a','1,'2,'3 ..1,2,3 are of course numbers NOT text, its just that the driver has put a single appostraphy before the number !

I know there is a bug with the ISAM driver but has anyone managed to solve this or has anyone have any alternatives ?

best regards

Reza

R Khan

View 3 Replies View Related

Openrowset And Excel

Apr 17, 2007

I'm doing an openrowset query on an excel sheet. (Using SQL Server 2005) Everything works great, except that I have one column that has both numeric and text data in the spreadsheet. The query returns that column as datatype varchar but puts nulls in the rows that have numeric data in the spreadsheet.

Any suggestions?

I run:

select *
from openrowset('microsoft.jet.oledb.4.0',
'Excel 8.0;database=[filepathandname],
'select * from [Sheet1$A4:G5000]')

on spreadsheet data that looks like:

Model_id Model_name
. . .
123 t4556
124 x225
125 455
. . .

and get something like . . . .

Model_id Model_name
. . .
123 t4556
124 x225
125 NULL
. . .

View 1 Replies View Related

Openrowset Views

Nov 30, 2007

Hi I have a table like:

LIB TABLENAME TABLEDESCR FIELDNAME FIELDDESCR
BISxxSETALPA0AsometableBS12A0somefield
BISxxSETALPA0AsometablePERCA0somotherfield
BISxxSETALPA1AsomeothertableCMPNA1somefield2
BISxxSETALPA1AsomeothertableMERIA1someotherfield2
BISFFBUAALPA1AanothertablePAARSsomefield3

and would like to create views for each distinct table, using openrowset.
An added complexity is that the library name depends on the company code (i.e. BISxxSET.ALPA0A turns to BIS03SET.ALPA0A for company 03 whereas BSFFBUA.ALPA1A remains intact).

Thanks in advance

Kyriakos

View 4 Replies View Related

Openrowset And Mdb -Files

Jul 23, 2005

Hy Forum !I tried to do somsthing like this:CREATE PROCEDURE dbo.maches ASselect * from openrowset('Microsoft.Jet.OLEDB.4.0','C: empFehler.mdb'; 'Administrator'; ' ' , Fehlerliste)This user 'Admistrator' exists and there is no password for the .mdbfile. In the end the syntax checker tells me:Fehler 7303: Datenquellenoblekt von OLE DB Provider'Microsoft.Jet.OLEDB.4.0' konnte nicht initialisiert werden.I'm using Access 2000 and SQL Server 7.Thank you

View 1 Replies View Related

XQuery Vs OpenRowset

Apr 5, 2006

Please let me know the advantages and disadvantages of XQuery vsOpenRowSet in SQL Server 2005. Which would be better?Regards,Shilpa

View 1 Replies View Related

Using OPENROWSET With An IP Address

Jan 11, 2007

Hi

I've got an openrowset query that works perfectly if I enter the computer name, but it fails when I enter the IP address.

Is there a setting somewhere that I need to enable to make this happen?

Thanks in advance

View 5 Replies View Related

Use OPENROWSET With Web Address?

Aug 28, 2006

I have an excel file on a web server on a different location to the sql server. I want to use OPENROWSET to query the excel file, but it doesn't seem to like using a URL.

Is this the case, or am I doing it wrong? Works fine when I use a local address (eg c:excelfile.xls) when testing locally, but I need to use a URL in production.

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=http://mydot.com/excelfile.xls','SELECT * FROM [page1$]')

View 1 Replies View Related

Openrowset Error

Jul 22, 2006

I have an access database from which i want to use data in sql server if a table has column with values like 6.32404E-244 i've got an error message like:

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' for linked server '(null)' returned invalid data for column '[Microsoft.Jet.OLEDB.4.0].Stoc_Max'

a simple select like 'SELECT * FROM OPENROWSET(.....,table) gives me this error.

View 3 Replies View Related

Syntax Of OpenRowset With UDL?

Oct 25, 2007



Hi All,

Does anyone know or have a sample of a syntax of OpenRowset using a UDL file?

Regards,
Joseph

View 1 Replies View Related

Why Does OPENROWSET Not Connect?

May 10, 2007

We have lots of OPENROWSET usage here, all with embedded user id's and passwords. In an attempt to find a way to eliminate such a foolish practice I created a system DSN on my PC and tried to use it to connect to our sqlserver 2000 database as follows:



SELECT a.*
FROM OPENROWSET('MSDASQL','DSN=TargetDB',
'SELECT * FROM table1') AS a




Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' reported an error. Authentication failed.
[OLE/DB provider returned message: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.]
OLE DB error trace [OLE/DB Provider 'MSDASQL' IDBInitialize::Initialize returned 0x80040e4d: Authentication failed.].


I thought the reason to create an ODBC system data source was to not have to enter credentials in code but use the credentials in the system DSN. I guess I was wrong. Is there any way to not embed user id's and passwords in OPENROWSET code? Having user id's and passwords in code is dangerous and foolish and I am surprised people do it.

View 4 Replies View Related

OPENROWSET T-SQL Function

Jul 11, 2006

Hi everyone,
I have some doubts about OPENROWSET T-SQL function . According to my knowledges about this, openrowset function provide us to use a data from a different Server only that time that we use this function. After we use this function, there is no any linked server trace on the local server. So is this true ?
I see that everyone use different parameter for this function. For instance, everyone firstly use OLE DB name and then the second srvprovider name changes programmer to programmer, so why ?
And lastly, I wonder about the relationship between ad hoc method and openrowSet function.

Thanks

View 12 Replies View Related

Problem With OPENROWSET

Aug 21, 2007

Hi!
I'm using OPENROWSET to import data from an excel file into a MS SQL table.I got it to work.....Now,my problem is that not all the data from the SQL table is imported and some values are different than the ones in the excel file.
For example,in the excel file,I have the value:87987845.In the SQL table,the value is:8.79878e+007.Any idea on what causes this?

View 8 Replies View Related

Regarding Openrowset Vs SSIS

Apr 18, 2008

hey..

I have to loop through number of tables on a remote servers.
Now i have witten a script(simple sql script) which loops though tables names and gets data using OpenRowSet().

My alternative way is through SSIS, keeping RetainSameConnecion=True, and then looping.


My question is,

Does calling OpenRowSet, creates a new connection each time the statement is executed?
If Not, then how's SSIS better in this case?
(please confirm that, since i was not able to see any audit login/logout in profiler)

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

Here's how i tested it..

I executed OPENROWSET 3 times in a sequence. But in Profiler i see only following events..

Audit Login
Batch Started
Batch Completed
RPC:Completed.
RPC:Completed.
:
:
:
:

RPC:Completed.


I'm intersted only to see if the login happens three time, but i'm not able to see that. Also, there was no Audit Logout.
Does SQL Server automatically pool connections ?
If i run Openrowset 3 times, shouldn't it open & close connection 3 times ?

Please clarify.

View 1 Replies View Related

Error With Openrowset

May 17, 2007

I have a text file, that I need to import to SQL. I am trying to do this using OPENROWSET. This is the qry i use below.



select * from OpenRowset('MSDASQL',
'Driver={Microsoft Text Driver
(*.txt; *.csv)};
DefaultDir=c:edge;',
'select * from
vwConstrLendingLoanDefiDetailReady.txt')



I have created a System DSN, For the microsoft text driver. Anyhow it throws this error:

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' reported an error.
[OLE/DB provider returned message: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified]
OLE DB error trace [OLE/DB Provider 'MSDASQL' IDBInitialize::Initialize returned 0x80004005: ].



Any idea why?

View 5 Replies View Related

An OpenRowset Little Doubt

Aug 11, 2006

Hi all.

Seeing that the old system table syslang is no longer updateable(Not even in DAC) i decided to take a look at the definition of it, just to see where the languages are stored.(out of curiosity)

Select Object_Definition(Object_Id('SysLanguages'))

and it returns

Select .......

FROM OpenRowset(TABLE SYSLANG)

The odd thing is I tried to run that query but it gives me an error telling an incorrect sintax near TABLE.

so, the question is if does anybody knows why i can't run the same query that the object_definition returned?

any comments are most apreciated

View 3 Replies View Related

Dynamic Sql Using Openrowset

Sep 21, 2007

can someone tell me why the upper part of the dynamic sql doesn't work while the lower does? i use openrowset to connect to Oracle. thanks!



declare @abc varchar(10)

select @abc = 'table20070921'

execute ('select a.* from OPENROWSET(''MSDAORA'',''SCHEME1'';''USER'';''PASSWORD'',
''select * from ' + @abc + ' where flag = ''abc'') as a')


Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'abc'.
Msg 105, Level 15, State 1, Line 2
Unclosed quotation mark after the character string ') as a'.


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


declare @abc varchar(10)

select @abc = 'table20070921'


execute ('select a.* from OPENROWSET(''MSDAORA'',''SCHEME1'';''USER'';''PASSWORD'',
''select * from ' + @abc + ' where cust_num = 123456'') as a')



View 1 Replies View Related

SQL2005 OPENROWSET

Dec 4, 2007

Hi!

I'm working with SQL 2005 and I want to connect to other server but i can't use linked server option because of secutirty policies.

In the remot server I have a stored procedure which retrieve me information depending on one header and the date i'm consulting. Then I use that information in my local server and i need to automate the process.

I have been trying with OPENROWSET and it works ok, but just with the first header, when I execute it with other header it doesn't work.


Select * from OPENROWSET('SQLOLEDB',Server; 'user';'pwd', 'Exec servidor.esquema.sp_Consulta 2,''20070101'',''20071031''')
______________________________

Mens. 7355, Nivel 16, Estado 1, LĂ­nea 1

The OLE DB provider "SQLNCLI" for linked server "(null)" supplied inconsistent metadata for a column. The name was changed at execution time.


Another issue i want to solve is that i want to sent the date as a parameter, 'cause i need the information montly.
I was reading that the openrowset and opendatasource are macros not functions, I think that's why it doesn't accept parameters in the string of the query, but now i don't know how to do to work with all the information (remote and local) without OPENROWSET, OPENDATASOURCE, LINK SERVER or an SSIS.

Help plis!!!

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved