Passing Variable Values Into A Nested SQL In An OLEDB Datasource

Aug 21, 2007

All:
I am trying to code the following SQL into an OLEDB data source but it is not allowing me to do so because I think the variables are nested in multiple SQL statements. I have seen other posts that suggest using a variable to store the SQL but I am not sure how it will work.

I would also like to mention that the OLEDB source executes from within a For Each loop that is actually passing the values for the variables, which was one of the reasons I got stumped on how I could have a variable store the SQL.

Here is the SQL:


select b.ProgramID, b.ProductCode, b.BuyerID, b.Vendor,sum(a.Ordered) As Qty_Pruchased
From SXE..POLine a INNER JOIN
(SELECT VIR_Program.ProgramID, VIR_ActiveSKU.ProductCode, VIR_ActiveSKU.BuyerID, Vendor
FROM VIR_Program INNER JOIN
VIR_ActiveSKU ON VIR_Program.ProgramID = VIR_ActiveSKU.ProgramID
INNER JOIN Vendor ON VIR_Program.VendorID = Vendor.VendorID
WHERE ProgramFreq=?) b
ON a.ProductCode = b.ProductCode
WHERE a.TransDate >=? AND
a.TransDate ?
Group By b.ProgramID, b.ProductCode, b.BuyerID, b.Vendor

Thanks!

View 5 Replies


ADVERTISEMENT

SQL Server 2014 :: Passing Multiple Columns Values From Query To One Variable?

Aug 10, 2014

Is it possible to assign multiple columns from a SQL query to one variable. In the below query I have different variable (email, fname, month_last_taken) from same query being assigned to different columns, can i pass all columns to one variable only and then extract that column out of that variable later? This way I just need to write the query once in the complete block.

DECLARE @email varchar(500)
,@intFlag INT
,@INTFLAGMAX int
,@TABLE_NAME VARCHAR(100)

[code].....

View 1 Replies View Related

Importing From An OLEDB Datasource Into A SQL Database

Mar 18, 2008

Hi,

I have a proprietary OLEDB data source that works alongside a SQL database. Both are pretty big. I am trying to find a fast way of copying the data from the OLE source into a table in the SQL database. I am working in ASP.NET, and the easiest way is to have 2 connections, open the OLEDB and fill a datatable, then go through the table line by line and do a parametized insert. That works but takes far too long.

I am looking for something along the lines of "SELECT INTO tblB FROM tblA", or even "INSERT INTO tblB SELECT * FROM tblA", anything that is faster than the above. Can you do this in SQL but accessing an OLEDB datasource?

Cheers,

Dave

View 1 Replies View Related

Oledb Source Issues &&<column Name&&> Cannot Be Found In Datasource

Oct 4, 2007



Good morning,

I have written a package which accepts variables for the server, initial catalog & table name.

I execute sql to drop the following stored procedure, then following sql statement to create it.

================================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE procedure [dbo].[SP_CreateMatchProc]
@sTable varchar(300)
as
BEGIN
SET NOCOUNT ON
declare @cmd nvarchar(2000)
set @cmd = ''''
Set @cmd = 'SELECT REPLACE(field1 + field2 + field3 + field4 + field5, '' '', '''') AS dBString '
+ 'FROM ' + @sTable + ' ORDER BY <table>_ID COLLATE Latin1_General_CI_AS'
exec (@cmd)
END
GO

================================================================



Then in the Oledb source (validateexternalmetadata = false) I use "sqlcommand from variable" with a variable value of "SP_CreateMatchProc '<tableName>'"

The package runs fine in the IDE regardless of variable values, but when I created a batch file which calls dtexec I get a failure:

Error: 2007-10-04 08:46:42.82
Code: 0xC0202005
Source: Data Flow Task OLE DB Source [310]
Description: Column "dBString" cannot be found at the datasource.
End Error
Log:
Name: OnError
Start Time: 2007-10-04 08:46:42
End Time: 2007-10-04 08:46:42
End Log
Log:
Name: OnError
Start Time: 2007-10-04 08:46:42
End Time: 2007-10-04 08:46:42
End Log
Error: 2007-10-04 08:46:42.82
Code: 0xC004701A
Source: Data Flow Task DTS.Pipeline
Description: component "OLE DB Source" (310) failed the pre-execute phase and returned error code 0xC0202005.
End Error


with the ValidateExternalMetadata set to TRUE I get

Error: 2007-10-04 09:21:35.20
Code: 0xC004706B
Source: Data Flow Task DTS.Pipeline
Description: "component "OLE DB Source" (10621)" failed validation and returned validation status "VS_NEEDSNEWMETADATA".
End Error


the most notable thing I see there is that it looks like a different ID (310) with out the validation and (10621) with it.

Any help would be greatly appreciated.



View 8 Replies View Related

Passing NT Authentication Thru OLEDB

Jan 2, 2004

I've got an intranet page that connects to my SQL server, and I'm trying to force it to use NT Authentication when it does.

Already the Intranet uses NT Challenge-and-response authentication so that when I go to an intranet page I have to login. But then when I go to the page that connects to SQL, I get:

Microsoft OLE DB Provider for SQL Server error '80040e4d'

Login failed for user 'IUSR_COMPUTERNAME'.

Why isn't it passing MY user id? Why is it trying to use the anonymous IUSR id?

View 6 Replies View Related

Passing A SSIS Global Variable To A Declared Variable In A Query In SQL Task

Mar 6, 2008

I have a SQL Task that updates running totals on a record inserted using a Data Flow Task. The package runs without error, but the actual row does not calculate the running totals. I suspect that the inserted record is not committed until the package completes and the SQL Task is seeing the previous record as the current. Here is the code in the SQL Task:

DECLARE @DV INT;
SET @DV = (SELECT MAX(DateValue) FROM tblTG);
DECLARE @PV INT;
SET @PV = @DV - 1;

I've not been successful in passing a SSIS global variable to a declared parameter, but is it possible to do this:

DECLARE @DV INT;
SET @DV = ?;
DECLARE @PV INT;
SET @PV = @DV - 1;


I have almost 50 references to these parameters in the query so a substitution would be helpful.

Dan

View 4 Replies View Related

Passing Variables In OLEDB Source

Jul 31, 2006

Hi,

I have created lastUpdatedDate variable on package level. I have run a sql task and store a date in that variable.

now i am trying to pass that variable as parameter to oledb source connection (using command). it seems that we cant pass parameter in any sub query or derived table in query. its only working in outer query as soon as we place ? in WHERE clause of inner query it start throwing an 'Syntax Error' error saying that connection provider might not support that.

any idea ?????

I dont want to use command variables as my query is going to be quite big.

Note : I have tried Sql Server Native and OLEDB provider for sql server and this behaviour is seems to be constant in both.

Thanks,

Furrukh baig

View 2 Replies View Related

Passing Parameters To Nested Parameter Queries

Jul 20, 2005

Though I am a novice to MS SQL server (2000 I believe), I can do almost!everything I need. Maybe not efficiently, but usefully. However, I havea problem -- a complex query problem...I can create a parameter query in a stored procedure, but how do I usethe result set of a parameter query in a select query (in the same oranother sp)? In short, if a select query contains a result table that isgenerated as a parameter query, how do I pass the parameter through theselect query to the nested parameter query?For example, if I have a sp parameter query called [e_typerows], I couldwrite the following select query which uses the (single) result set from[e_typerows] plus other tables or views:SELECT TOP 100 PERCENT bi_occ_01_e.row, bi_occ_01_e.pos,bi_dictionary_e.typestring, bi_occ_01_e.shadowFROM bi_dictionary_e INNER JOIN(bi_occ_01_e INNER JOIN[e_typerows] ON bi_occ_01_e.row = [e_typerows].row) ONbi_dictionary_e.typeid = bi_occ_01_e.typeidORDER BY bi_occ_01_e.row, bi_occ_01_e.posEven though [e_typerows] is a (storted procedure) parameter query thiswill work IF my parameter in [e_typerows] has a default, say "yyyy". Inthe default case no parameter needs passing. But what if it doesn't havea default value or if I need to pass a parameter to it?Is there any way to replace[e_typerows]in the above query with somethinglike [e_typerows @myparameter='xxxx']? (Maybe I should try that! I'veseen nothing about it though.)My parameter query, [e_typerows], looks like this in fact:@typestringparameter varchar(100) = "yyyy"SELECT dbo.bi_dictionary_e.typestring, dbo.bi_occ_01_e.rowFROM dbo.bi_occ_01_e INNER JOINdbo.bi_dictionary_e ONdbo.bi_occ_01_e.typeid = dbo.bi_dictionary_e.typeidGROUP BY dbo.bi_dictionary_e.typestring,dbo.bi_occ_01_e.rowHAVING (dbo.bi_dictionary_e.typestring = @typestringparameter)Any suggestions would be greatly appreciated! (For the moment, I firstgenerate the parameter query result set, then I loop through each row ofthat result set and do a select query with that row as a parameter --very complicated!, though it does work.)

View 3 Replies View Related

Help Passing UserName To The WHEREclause Using The Configure DataSource Wizzard In Visual Studio UI

May 31, 2007

 (I asked this question in another forum, but think it may be more of  asql question)Hi.I bet this is a 101 question, but i'd appreciate any help!I am in the 'where...' section of the configure data source wizzard .(Visual Studio 2005) Column:(From my table) I select 'UserName' from drop-downOperator: I select '=' from drop-downBUT how do I get the UserName (The user is signed into the app)  to pass to the where clause?Is it from the Form? Profile? Session?Ive tried         Form.Page.User.Identity.Name.ToString;                    Form.NamingContainer.Page.User.Identity.Name.ToString;                    Profile.UserName; NOTHING works. IF I set the default value to a user name (eg joe_user) it retrieves fine, but I need it to retrieve for the currently signed in user. THANKS In advance.... Dan

View 7 Replies View Related

C# Variable In SQL Datasource?

Apr 8, 2008

I have a single variable to be utilitized in my SQL Where clause...
Select *FROM projectsWhere project_id = @id
 How do I use this c# variable in the datasource?
 string TableID; TableID  = "192.AB";
 I know this is simple, but I figured I'd ask. I don't want to do a work around , like a hidden textbox with the value assigned, and then link the datasource to the tb control, seems extremely hackish.
 
 
 

View 3 Replies View Related

SSIS Datasource = Variable

Mar 24, 2008

I need to be able to, at run time, set the location of a DataSource in an SSIS package.

I've searched and searched and beat my head against the wall till I'm bloody but I can't figure this out.

Can anyone please point me in the right direction?

View 4 Replies View Related

Use Variable For Datasource In Opendatasource

May 4, 2006

I would like to create a stored procedure that imports an Excel file toa sql server table. I need to be able to pass the path to thespreadsheet to the stored procedure like so:CREATE PROCEDURE dbo.ImportSpreadsheet(@Path nvarchar(120))ASSELECT * INTO AuditFROM OPENDATASOURCE( 'Microsoft.Jet.OLEDB.4.0','Data Source = ' + @Path + ';Extended Properties=Excel 8.0')...Audit$I will call the stored procedure from within my .NET application andpass it the path as @Path. The path will be chosen by the user at runtime and will be something similar toC:SpreadsheetsAudits.xls.I can make this run in the Query Analyzer:SELECT * INTO AuditFROM OPENDATASOURCE( 'Microsoft.Jet.OLEDB.4.0','Data Source = ''C:SpreadsheetsAudits.xlsAudit_TC.xls'';Extend edProperties=Excel 8.0')...Audit$I could run the SQL directly from my app, but I like to use storedprocs whenever I can for the speed and flexibility. I can change thestored proc and not have to recompile/reinstall the app.Any help would be greatly appreciated.

View 1 Replies View Related

Passing Variable Value Through Environment Variable

Feb 15, 2008



Hi All!

I have a parent package that contains two children... The second child depends on the succes of the first child.

THe first child generates a variable value and stores it in an Environment variable ( Visibility - All ) ...After the first succeeds, the second will start executing and will pick up the variable value from environment variable( through package configuration setting )...

Unfortunately, this doesn't work...As the second child picks the stale value of the environment variables...Essentially it assigns variable value not after the first child is finished, but right at the beginning of parent execution...

I tried to execute coth children as Out Of Proc as well as In Proc...The same

Would anybody have an idea how to resolve this problem?

Thanks in advance for any help!

Vladimir

View 5 Replies View Related

How To Check DataSource Control For Values

Jan 18, 2008

Hey all,
 I was wondering what the best method of checking on page_load if a datasource control is pulling back nothing from a database.  I want to display a message explaining that there is no data to be displayed.  How would I go about doing that?  I have tried searching google and whatnot but didn't find anything really helpful.
Here is the current code for the data source control.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|EventInsider.mdf;Integrated Security=True;User Instance=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT Events_Groups.GroupName, Events_Groups.GroupID FROM Events_GroupMembership INNER JOIN Events_Groups ON Events_GroupMembership.GroupID = Events_Groups.GroupID WHERE (Events_GroupMembership.UserID = @UserID)">
<SelectParameters>
<asp:SessionParameter Name="UserID" SessionField="UserID" />
</SelectParameters>
</asp:SqlDataSource>
 But I have no idea what the code behind would be to check it on page_load.  If there is no way to particularly do this, do you have to do it per control?  Like dropdownbox's or gridviews?  I am just confused on how to check to make sure there is data to be displayed.
Thanks,
Chris

View 3 Replies View Related

I Am Trying To Use Nested Cursors. But Is There A Way To Use More Than One @@FETCHSTATUS Variable ?

Apr 18, 2008

I need to use a nested cursor in SQL server 2005. I have never done this before. The problem here is that I need to use "@@FETCH_STATUS' twice.Once for my inner loop and once for my outer loop. If there is a way to use two different @@FETCH_STATUS variables at once, I would like to know how.
Here is my code. The inner loop is currently pseudo code and I just need to figure out how to code it.
DECLARE @mycur1 CURSORDECLARE @mycur2 CURSORDECLARE @InMarketId INTSET @InMarketId=575 -- Hard code for now. Just for testing.DECLARE @test VARCHAR(10)SET @mycur1 = CURSORSET FORSELECT SubDivisionId FROM SubDivision WHERE MarketId=@InMarketIdOPEN @mycur1FETCH NEXT FROM @mycur1 INTO @testWHILE @@FETCH_STATUS = 0 BEGIN
 PRINT @test--       Begin Inner Nested Loop--         FOR EACH SubDivisionId in SubDivisionSubMarket SDSM delete from SubMarket SM Where SDSM.SubMarketId=SM.SubMarketId
--       End of Inner nested Loop
  FETCH NEXT FROM @mycur1 INTO @test    ENDDEALLOCATE @mycur1------------------------------------------Here are my three tables I am scripting agains and a description of each.
SubDivision-----------SubDivisionIdMarketIdNameDescriptionCreatedBy
SubDivisionSubMarket--------------------SubDivisionIdSubMarketId
SubMarket--------------------SubMarketIdCodeDescriptionLastUpdateDate

View 2 Replies View Related

Variable Inside A Nested Loop

Jul 20, 2005

I am trying to write a utility/query to get a report from a table. Belowis the some values in the table:table name: dba_daily_resource_usage_v1conn|loginame|dbname|cum_cpu|cum_io|cum_mem|last_b atch------------------------------------------------------------80 |farmds_w|Farm_R|4311 |88 |5305 |11/15/2004 11:3080 |abcdes_w|efgh_R|5000 |88 |4000 |11/15/2004 12:3045 |dcp_webu|DCP |5967 |75 |669 |11/16/2004 11:3095 |dcp_webu|XYZ |5967 |75 |669 |11/17/2004 11:30I need to write a query which for a given date (say 11/15/2004),generate a resource usage report for a given duration (say 3 days).Here is my query:************************************set quoted_identifier offdeclare @var1 intset @var1=0--BEGIN OUTER LOOPwhile @var1<=3 --INPUT runs the report for 3 daysbegindeclare @vstartdate char (10) --INPUT starting dateset @vstartdate='11/15/2004'--builds a range of datedeclare @var2 datetimeset @var2=(select distinct (dateadd(day,@var1,convert(varchar(10),last_batch,101)))--set @var2=(select distinct (dateadd(day,@var1,last_batch))from dba_daily_resource_usage_v1where convert(varchar (10),last_batch,101)=@vstartdate)set @var1=@var1+1 --increments a daydeclare @var5 varchar (12)--set dateformat mdy--converts the date into 11/15/2004 format from @var2set @var5="'"+(convert(varchar(10),@var2,101))+"'"--print @var5 produces '11/15/2004' as resultdeclare @vloginame varchar (50)declare @vdbname varchar (50)--BEGIN INNER LOOPdeclare cur1 cursor read_only forselect distinct loginame,dbname fromdba_daily_resource_usage_v1where convert(varchar (10),last_batch,101)=@var5--??????PROBLEM AREA ABOVE STATEMENT??????--print @var5 produces '11/15/2004' as result--however cursor is not being built and hence it exits the--inner loop (cursor)open cur1fetch next from cur1 into @vloginame, @vdbnamewhile @@fetch_status=0begin--print @var5 produces '11/15/2004' as resultdeclare @vl varchar (50)set @vl="'"+rtrim(@vloginame)+"'"declare @vd varchar (50)set @vd="'"+@vdbname+"'"--processes the cursorsdeclare @scr varchar (200)set @scr=("select max(cum_cpu) from dba_daily_resource_usage_v1 whereloginame="+@vl+" and dbname="+@vd+" and "+"convert(varchar(10),last_batch,101)="+@var5)--set @var3 =(select max(cum_cpu) from dba_daily_resource_usage_v1where--loginame=@vloginame and dbname=@vdbname--and convert(varchar (10),last_batch,101)=@var5)print @scr--exec @scrfetch next from cur1 into @vloginame, @vdbnameend--END INNER LOOPselect @var2 as "For date"deallocate cur1end--END OUTER LOOP************************************PROBLEM:Even though variable @var5 is being passed as '11/15/2004' inside thecursor fetch (see print @var5 inside the fetch), the value is not beingused to build the cursor. Hence, the cursor has no row set.Basically, the variable @var5 is not being processed/passed correctlyfrom outside the cursor to inside the cursor.Any help please.Thanks*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 3 Replies View Related

Use Variable As IN List For OleDB Command

Sep 27, 2007

Group,

First let me say that I'm new to SSIS, so be gentle with me.

I need to extract a limited set of data from a very large view in Oracle (I know, yuk!). The view contains millions of rows, but I only need the child matches of 343 unique keys in a one to many relationship. In pure SQL the query would look something like this.

Select proj, tn, rn, total FROM Oracle.view WHERE proj in (select distinct proj from MSSQL.dbo.projlist)

As you can see, this is an impossible query on many levels.

My first thought was to get the runtime list into a variable and use that variable as a parameter in the Oracle OleDb Source. Alas, the Oracle source will not allow me to add a parameter.

My second thought was to use a script component and build a SQL_Command string into a variable with all of my keys included. Then use the read_write variable as the SQL Command from variable in the Oracle Source. My attempts to construct such a variable expression have failed.

Any ideas would be appreciated.


RH

View 11 Replies View Related

Obtaining Values On Datasource Inserting Event

Nov 27, 2007

Hi,
I want to be able to spot when the same employee name gets added to my grid.  This is to ensure that I cannot not have the same firstname and lastname (i.e. cannot have 2 John Smiths).
It is kind of like spoting for duplicates but they are not PKs.  I was hoping if there was a way you could identify the the feild values on the "inserting" event of the datasource so I could put some logic in.  The reason for placing it there is because we have the e.cancel = true command.
Thanks in advance,
 Jon

View 5 Replies View Related

Linear Regression With Nested Explanation Variable

Jan 22, 2007

We are trying to create a model of linear regression with nested table. We used the create mining model sintax as follow :

create mining model rate_plan3002_nested2

( CUST_cycle LONG KEY,

VOICE_CHARGES double CONTINUOUS predict,

DUR_PARTNER_GRP_1 double regressor CONTINUOUS ,

nested_taarif_time_3002 table

( CUST_cycle long CONTINUOUS,

TARIFF_TIME text key,

TARIFF_VOICE_DUR_ALL double regressor CONTINUOUS

)

) using microsoft_linear_regression

INSERT INTO MINING STRUCTURE [rate_plan3002_nested2_Structure]

(CUST_cycle ,

VOICE_CHARGES ,

DUR_PARTNER_GRP_1 ,

[nested_taarif_time_3002](SKIP,TARIFF_TIME ,TARIFF_VOICE_DUR_ALL)

)

SHAPE {

OPENQUERY([Cell],

'SELECT CUST_cycle ,

VOICE_CHARGES ,

DUR_PARTNER_GRP_1

FROM dbo.panel_anality_3002

order by CUST_cycle ')}

APPEND

({OPENQUERY([Cell],

'select CUST_cycle,

TARIFF_TIME,

CYCLE_DATE

from dbo.nested_taarif_time_3002

order by CUST_cycle,TARIFF_TIME')

}

relate CUST_cycle to CUST_cycle

) as nested_taarif_time_3002



The results we got are a model with intercept only. if we don't use the nested variable (the red line) we get a rigth model . (we had more variable ....)

Is there a way to do this regression correctly?

Thanks,

Dror

View 7 Replies View Related

Transact SQL :: Casting A Variable To Nested Table?

Sep 24, 2015

Is there any way to convert a bind variable, which is a list of integer or string values, to nested table in MS SQL Server. I am looking for something like

CAST in Oracle, which converts a varray type column into a nested table. Do we have something like this in SQL Server.

in Oracle:

SELECT CAST(s.addresses AS address_book_t)
FROM states s
WHERE s.state_id = 111;

I have read about Table valued Parameter, but I am looking for another solution. 

View 4 Replies View Related

Transact SQL :: Insert Values From Variable Into Table Variable

Nov 4, 2015

CREATE TABLE #T(branchnumber VARCHAR(4000))

insert into #t(branchnumber) values (005)
insert into #t(branchnumber) values (090)
insert into #t(branchnumber) values (115)
insert into #t(branchnumber) values (210)
insert into #t(branchnumber) values (216)

[code]....

I have a parameter which should take multiple values into it and pass that to the code that i use. For, this i created a parameter and temporarily for testing i am passing some values into it.Using a dynamic SQL i am converting multiple values into multiple records as rows into another variable (called @QUERY). My question is, how to insert the values from variable into a table (table variable or temp table or CTE).OR Is there any way to parse the multiple values into a table. like if we pass multiple values into a parameter. those should go into a table as rows.

View 6 Replies View Related

To Access Global Variable Inside Oledb Command

Mar 13, 2008

Hi

How to use a global variable of a package inside oledb command

Scenario:
Glb_Rowcount Variable


I need to use this variable value inside oledb command.


P.S: No use of stored procedures and no script component

View 4 Replies View Related

Passing Value To A Variable

Aug 9, 2007



Hi,
This is pretty simple but I am doing somethin really stupid somewhere, I am trying to pass a value to a variable declared in a package using some SQL code, I declared a variable "var1" and assigned the scope to the package , then I dropped a execute SQL task within the package and wrote a simple sql code that would get the maximum id from a table, "select max(id) from table" , now I want to assign the variable this max value.so in the parameter mapping tab I select the variable give it a parameter name of 0 and size of -1 along with direction of "output". everythin looks simple but when I try to use this variable value in my next execute sql task it behaves weirdly, I am trying to update anothet table using this variable value, so I add another task and put this code in there " update table2 set id = ? " , and on the parameter mapping tab I set the direction as input, however when I look at the column it updated th column with a weird number , xomethin like "230072408" which doesnt mean anything. I know that tha max value of ID is 10.
Please help.

Thanks

View 13 Replies View Related

Writing Data To OLEDb Dest With The Table Name Set Via A Variable. (ValidateExternalMetadata Issue)

Feb 16, 2007

 

I am using a foreach loop, with the data from an ado recordset, which contains the table name that I wish to write data to an OLEDB data dest.  The table names are retrieved from an execute sql task in the an object var.  Within the foreach loop, for each table name, I then use a datareader to an ado.net source to pull data from that table, via an expression construct into a variable - i.e. "select * from " + @[User::table_name].  This works fine for the first table, in which mappings are setup using the SSIS design environment.  The data is retrieved.  I then use a variable and set the data access mode for the oledb destination to "Table name or view name variable".  This also saves data fine for the first table in the loop in the oledb dest.  When the next table name is retrieved from the ado provider in the foreach loop, the datareader fails, as it still thinks the metadata mappings are from the first table, which was used for the mapping in the design environment.  I.E. FIN_CLASS is a column from the first table in the loop. 

Error: 0xC0202005 at Data Flow Task, DataReader Source [7181]: Column "FIN_CLASS" cannot be found at the datasource.

I have set the following properties, that I thought (in my feeble mind), are supposed to avoid that behavior.  For the datareader, I set ValidateExternalMetadata to false, and for the data flow task (container for the datareader), I set DelayValidation to true.  These settings, according to the doc, are supposed to evaluate metadata for the datareader source at runtime (not design time), so that the column metadata is dynamic, and so that the subsequent oledb destination can use the "data access mode" for the oledb destination of "Table name or view name variable".  

If I cannot get this to work, I have 2 options: Use OPENQUERY via dynamic t-sql statements, OR create 30 separate flows in SSIS - one for each table - not looking forward to that one.

View 5 Replies View Related

SQL Server 2012 :: Nested Query Retrieving Min And Max Values?

Jul 16, 2015

I have a nested query that retrieves a min value. I would like to know how do i retrieve the corresponding time with that.

my data looks like this

valuevaluetime
1212/31/14 14:51
12.42/19/15 23:30
[highlight=#ffff11]10.92/21/15 6:40[/highlight]
13.21/25/15 20:47

My min value is 10.9 and i need the date 02/21/15

my nested query is as follows

( select min(cast(f.valuestr as float))
from bvfindings f
where f.ObjectName = 'Hematocrit'
and f.sessionid = s.sessionid
and f.ValueTime > s.open_time)

the above returns me the 10.9

i modified the query

select min(cast(f.valuestr as float)),
f.valuetime
from bvfindings f
where f.ObjectName = 'Hb'

but i get all values then.

View 6 Replies View Related

Passing Variable To SqlCommand

May 18, 2007

 Can't seem to pass a variable to the sql statement. I'd appreciate any help. I'm trying to pass pColName to  CommandText = "ALTER TABLE tb_roomInfo ADD @rColName  varchar(50);";Doesn't seem to work though. CODE:  [WebMethod]    public string addCol(string pColName)    {                    SqlConnection cnn = new SqlConnection(connString);        try        {                        cnn.Open();            SqlCommand cmd = new SqlCommand();            cmd.Connection = cnn;                       cmd.CommandText = "ALTER TABLE tb_roomInfo ADD @rColName  varchar(50);";            SqlParameter rColName = new SqlParameter("@rColName", pColName);            cmd.Parameters.Add(rColName);            int i = cmd.ExecuteNonQuery();            cnn.Close();            return "Insert Successful";        }        catch        {                        return "Insert Unsuccessful";        }    }

View 3 Replies View Related

SQL WHERE Clause Passing In Variable

Jun 14, 2007

Hi All, Would somebody be able to help me from pulling my hair out!??I have a form with a radiobuttonlist. I would like to change my select statement depending on what radiobutton value is selected.E.g.SELECT * FROM table WHERE <<variable from radiobuttonlist>> LIKE 'Y'So,if radiobutton value selected = 1, it will select * from column A  in the dbif radiobutton value select = 2, it will select from column B in the dband so on...  Am i attempting to do the impossible?Thanks All, 

View 4 Replies View Related

Passing Datetime Variable To A SP

Jan 18, 2008

Hello,
I have a SP that recevies a date value for a users date of birth called "dob".
However when passing it into the class which contains the Stored procedure it gives an error.
 Below is my code
please advice
Thanks
Ehi
 
  1
2 command.Parameters.Add(new SqlParameter("@usernames", SqlDbType.Int, 0, "RegionID"));
3 command.Parameters.Add(new SqlParameter("@username", SqlDbType.VarChar, 20, "username"));
4 command.Parameters.Add(new SqlParameter("@First_Name", SqlDbType.VarChar, 50, "First_Name"));
5 command.Parameters.Add(new SqlParameter("@Last_Name", SqlDbType.VarChar, 50, "Last_Name"));
6 command.Parameters.Add(new SqlParameter("@dob", SqlDbType.Date, 50, "dob"));
7
8 command.Parameters[0].Value = 4;
9 command.Parameters[1].Value = "username";
10 command.Parameters[2].Value = "First_Name";
11 command.Parameters[3].Value = "Last_Name";
12 command.Parameters[4].Value = DateTime.Parse(dob.Text);
 

HERE IS THE ERROR MESSAGE 
 Compiler Error Message: CS0103: The name 'dob' does not exist in the current context

Source Error:



Line 40: command.Parameters[2].Value = "First_Name";
Line 41: command.Parameters[3].Value = "Last_Name";
Line 42: command.Parameters[4].Value = DateTime.Parse(dob.Text);
Line 43:
Line 44: int i = command.ExecuteNonQuery();


Source File: c:inetpubwwwrootcellulant1App_Codesignup_data-entry.cs Line: 42  

View 7 Replies View Related

Passing Value To A Variable From Database

Apr 25, 2008

I am trying to get data from a database through a select statment and I want to pass the return query to a c# string variable. Any idea how can I do this?
 

View 2 Replies View Related

Passing Variable To Sql Statement

Apr 28, 2008

could anyone please help me to resolve this issue?
here's my sql query which retrieve last 3 month data
t.execute(SELECT * tbl1 where nmonth >= datepart(mm,DATEADD(month, -3, getdate())) or nmonth <=datepart(mm,getdate()) and empno='"+emppip+"'")
now instead of passing 3 in this query(datepart(mm,DATEADD(month, -3, getdate())) )
i need to pass a variable to retrieve data based on user requirements.
i tried this way,
dim mno as n
mno=4
t.execute(SELECT * tbl1 where nmonth >= datepart(mm,DATEADD(month, -'"+mno+"', getdate())) or nmonth <=datepart(mm,getdate()) and empno='"+emppip+"'")
its not working.
can i achieve this using stored procedure? or can i directly pass a variable to sql synatax?
thanks for any help   

View 8 Replies View Related

Passing A String Variable To Sql

May 11, 2008

hi there,
i am trying to pass a string which contains a string,
here is the code which is wrong :
{string sqlcommand = "select pnia.pnia_number, pnia.user_name, pnia.date_pnia, pnia.user_pnia, problem.problem, gormim.gorem_name, status.status_name from pnia,gormim,problem,status where (pnia.status='@p1' and status.status='@p1' and pnia.problem=problem.problem_num and pnia.gorem=gormim.gorem)";
OleDbCommand cmd = new OleDbCommand(sqlcommand,con);OleDbParameter p1 = new OleDbParameter("@p1",this.DropDownList4.SelectedItem.Value.ToString());
cmd.Parameters.Add(p1);
}
the problem is that the sql compailer doesnt take the parameter (@p1) as a string
if someone could help me with that it would be great !  tnx

View 2 Replies View Related

Passing A Query Into A Variable

Aug 9, 2007

What is the easiest way to pass a value into a variable...
TSQL...

declare @@test int

--select count(*) from authors
select count(*) into @@test from authors

View 1 Replies View Related

Syntax For Passing Variable-usp

May 20, 2007

hi guys what is the syntax for using the passing variable part into the name of a table in a store procedure. in particular: (assume already declared the variable periodseq.


select *
into Temp_Usage_@periodseq
from Master_usage
where Master_usage.PERIODSEQ = @periodseq


in particular the Temp_Usage_@periodseq line of code, how do i "add" the periodseq (which is a number) to the end of the name of Temp_Usage, i.e: Temp_Usage_112
is the syntax an & like Temp_Usage_&@periodseq?
Cheers
Champinco

View 1 Replies View Related







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