Store Data Into Temp Array

Sep 13, 2006

How can you loop over a data reader and save the current row to a temp array of some sort and return this array back to the caller?



SqlDecimal total = 0;
SqlConnection conn = new SqlConnection("Context Connection=true");
SqlCommand cmd = new SqlCommand(@"SELECT column1, column2, column3
FROM table ", conn);

conn.Open();

SqlDataReader rdr = cmd.ExecuteReader();


while (rdr.Read())
{
if (rdr.GetSqlString(1) == "01")
{
// ADD the current record to a temp list
total = total + rdr.GetSqlDecimal(2);
}

}

SqlContext.Pipe.Send(total.ToString());


// RETURN the temp list

rdr.Close();
conn.Close();

View 4 Replies


ADVERTISEMENT

Create Temp Table To Store Data From Database(mssql)

Jun 26, 2007

I am a starter of vb.net and trying to build a web application. Do anyone know how to create a temp table to store data from database? I need to extract data from 3 different tables (Profile,Family,Quali). Therefore, i need to use 3 different queries to extract from the 3 tables and then store it in the temp table. Then, i need to output the data from temp table to the screen. Do anyone can help me?

View 2 Replies View Related

Array In Store Procedure

Jul 20, 2005

Dear all,Sometimes I happened the require that the number of input parametersof SP is not fixed, Can sql T-SQL handle the array (dynamic array)?Does anybody ever used an array name as the input parameter to callthe SP?thanks,Robert

View 3 Replies View Related

Store System.Array In SQL

Apr 10, 2007

Hi

I am having a object System.Array and i want to store in SQL database.The object will be array of byte, but in SQL server doesn't have anytype to store that. Can you please tell me what is the most appropriate data type in SQL that i should use? Do i need conversion to store and get data in SQL database.

Thanks a lot for your help. I reall do appreciate that.

Maverick

View 4 Replies View Related

What Type Of Field Should I Use To Store An Array Or Datatable?

Feb 25, 2005

Hi - I'm using Session variables to store information (sort of webshop).

The sessions are a mix of the usual straightforward strings, wich are no problem - but I also have a DataTable which I store in a session variable, and I also have an array, which I store in a session variable eg. session("day")(x) where x is the item in the array.

I want to give my users the ability to store the items they've selected in my database, but have no idea of what type of field I should use for the datatable and array session variable. Should I use a TEXT field, or is there another more appropriate one'?

I'm using SQL Server 2000.

Thanks for any help,

Mark

View 3 Replies View Related

Store Procedures: Pass Array Of Numbers For IN Clause?

May 24, 2006

How does one pass into a Stored Procedure an array of numbers to be used in an IN clause? If I pass "1,2" in a VARCHAR, the stored procedure sees only the first number (1 in this case).
I'm using VB and ADO.NET, but I don't know how to set up the stored procedure for an array. Is there a parsing function to do this?
CREATE PROCEDURE TestInClause( @TeamList VARCHAR)ASSELECT Name FROM Teams WHERE TeamID IN (@TeamList); /* sees only 1st number */GO

View 2 Replies View Related

How To: Store And Retrieve Images In A Database As A Byte Array.

Feb 28, 2008

I€™ve inherited a project from one of the guys on our team who will be out sick for a while. He developed two for marshaling data between System.Drawing.Image and System.Byte(). He€™s storing the byte array data in a database image field.

I€™ve retrieved the byte array data from his database image fields and have successfully converted them to images using his ConvertByteArrayToImage method below. I have also converted and image to a byte array with his ConvertImageToByteArray method below and succfully stored the data in a database image field. However, when I retrieve the byte array data that I stored in the database the last line in his ConvertByteArrayToImage method throws an exception (Parameter is not valid). I€™ve not been able to find a working copy of his code that€™s storing the byte array data. Does anyone see anything I€™m overlooking?

Imports System.Drawing
Imports System.IO

Public Sub InsertImage(ByVal pFilename As String)

Try

Dim lImage As Image
Dim lBA() As Byte
Dim lSQL As String
Dim lQuery As Alcon.SQLServer.Database.clsQuery
Dim lParameters As New Alcon.SQLServer.Database.clsParameters

lImage = Image.FromFile(pFilename)

ConvertImageToByteArray(lImage, lBA)

' Initialization
lQuery = New Alcon.SQLServer.Database.clsQuery(mConnection)

lSQL = ""
lSQL += "INSERT INTO [TBL_PCL_LENS_DATA]("
lSQL += "[SerialNumber], "
lSQL += "[ProcessedDate], "
lSQL += "[CartonLabelImage]) "
lSQL += "VALUES ("
lSQL += "@SerialNumber, "
lSQL += "@ProcessedDate, "
lSQL += "@CartonLabelImage "
lSQL += ")"

lParameters.Add("@SerialNumber", SqlDbType.VarChar, ParameterDirection.Input, mSerialNumber)
lParameters.Add("@ProcessedDate", SqlDbType.DateTime, ParameterDirection.Input, Now)
lParameters.Add("@CartonLabelImage", SqlDbType.Image, ParameterDirection.Input, lBA)

' Execute query
lQuery.Execute(lSQL, lParameters)

Catch ex As Exception
Throw
End Try

End Sub

ConvertByteArrayToImage(ByVal pBA() As Byte, ByRef pImage As Image)

Try

' Declaration
Dim lMS As MemoryStream

' Initialization
lMS = New MemoryStream(pBA, 0, pBA.Length)
lMS.Write(pBA, 0, pBA.Length)
lMS.Position = 0

' Create image
pImage = Image.FromStream(lMS, True)

Catch ex As Exception
Throw
End Try

End Sub

ConvertImageToByteArray(ByVal pImage As Image, ByRef pBA() As Byte)

Try

' Declaration
Dim lBM As Bitmap
Dim lBR As BinaryReader
Dim lMS As New MemoryStream

' Initialization
lBM = New Bitmap(pImage)
lBM.Save(lMS, Imaging.ImageFormat.Png)
lBR = New BinaryReader(lMS)

' Create byte array
pBA = lBR.ReadBytes(lMS.Length)

Catch ex As Exception
Throw
End Try

End Sub

View 1 Replies View Related

How Do I Store Results In TEMP TABLE?

Jul 7, 2005

I'm writing a search engine and I want to make a search and then, after
I've recieved the results, put them into some sort of temporary(in
mememory) table so that I can do another query on that temporary table.

I saw something about  temp tables (in T-SQL)  in the
help guide, but I still want to know how to do a query on a regular
table and then store those results in a temporary table to perform a
query on that. Could anyone show me some example or something?

View 3 Replies View Related

Cursor To Store Value In Temp Table

Mar 20, 2008

Following sp gives wrong result whats wrong with following cursor?

ALTER PROCEDURE [dbo].[spPMPT_GetProjectBenefitDetailsForAssess]

@ProjectBenefitID INT

AS

SET NOCOUNT ON


DECLARE @ErrorMsgID INT
DECLARE@ErrorMsg VARCHAR(200)

DECLARE @TEMP_BENEFIT
TABLE (ActualQuantity INT,
ExpectedQuantity INT,
ActualQulity VARCHAR(2000),
ExpectedQulity VARCHAR(2000) )


DECLARE @AssessBenefitID INT
DECLARE @ActualQuantity INT
DECLARE @ExpectedQuantity INT
DECLARE @ActualQuality VARCHAR(2000)
DECLARE @ExpectedQuality VARCHAR(2000)
DECLARE @AssessFlag CHAR
DECLARE CUR_BENEFIT CURSOR FOR
SELECT AssessBenefitID,ProjectBenefitID,AssessFlag FROM PMPT_AssessBenefit WHERE ProjectBenefitID=@ProjectBenefitID

OPEN CUR_BENEFIT


FETCH NEXT FROM CUR_BENEFIT INTO @AssessBenefitID,@ProjectBenefitID,@AssessFlag




WHILE @@FETCH_STATUS = 0
BEGIN



SELECT @ActualQuantity=Quantity FROM dbo.PMPT_AssessBenefit WHERE AssessFlag='A' AND AssessBenefitID=@AssessBenefitID AND ProjectBenefitID=@ProjectBenefitID
SELECT @ExpectedQuantity=Quantity FROM dbo.PMPT_AssessBenefit WHERE AssessFlag='E' AND AssessBenefitID=@AssessBenefitID AND ProjectBenefitID=@ProjectBenefitID
SELECT @ActualQuality=Quality FROM dbo.PMPT_AssessBenefit WHERE AssessFlag='A' AND AssessBenefitID=@AssessBenefitID AND ProjectBenefitID=@ProjectBenefitID
SELECT @ExpectedQuality=Quality FROM dbo.PMPT_AssessBenefit WHERE AssessFlag='E' AND AssessBenefitID=@AssessBenefitID AND ProjectBenefitID=@ProjectBenefitID



INSERT INTO @TEMP_BENEFIT (ActualQuantity ,
ExpectedQuantity ,
ActualQulity ,
ExpectedQulity )VALUES(@ActualQuantity,@ExpectedQuantity,@ActualQuality,@ExpectedQuality)


FETCH NEXT FROM CUR_BENEFIT INTO @AssessBenefitID,@ProjectBenefitID,@AssessFlag
END

CLOSE CUR_BENEFIT
DEALLOCATE CUR_BENEFIT


SELECT * FROM @TEMP_BENEFIT

View 3 Replies View Related

Temp Table In Store Procedures

Jan 25, 2008

Can any one please tell me where i am going wrong..




Code Snippet
create proc SP_PercentageRMU
as
SELECT cast (sum([Usage Qty]) as [decimal] (28,8))as 'TUsageQty'
,RAW_MATERIAL
into #TZMelt_Pound
FROM [LatrobeOCT].[dbo].[ZMelt_Pound]

group by RAW_MATERIAL
GO
select [Usage Qty],(case when r.raw_material = z.raw_material
then cast ((r.[usage QTY] / z.TUsageQty) as decimal (28,8))
else 0
end) as '%UsageQty'
,r.[PRODL]

,r.RAW_MATERIAL
,r.[GRADECODE]
into #PZMelt_Pound
FROM [LatrobeOCT].[dbo].[ZMelt_Pound]r
inner join #TZMelt_Pound z on r.raw_material = z.raw_material

drop table #TZMelt_Pound
go






error

Msg 208, Level 16, State 0, Line 2

Invalid object name '#TZMelt_Pound'.

View 6 Replies View Related

Unable To Extend Temp Segment By 64 In Tablespace TEMP (SSIS Error While Copying Data From Oracle)

Oct 22, 2007

I am transferring data from oracle and getting below error message.

I using 4 data flow tasks with in a single control flow and all the 4 tasks quueries same table but populates data in to different sql tables based on the where contidion

[OLE DB Source 1 [853]] Error: An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "ORA-01652: unable to extend temp segment by 64 in tablespace TEMP ".

View 4 Replies View Related

Store The Stored Procedure Result In A Temp. Tabl

Mar 28, 2008

All,

I'm trying to store the results of my store procedure in a temp table. when I try it, I got the error saying...

"Insert exec cannot be nested"

I suspsect this is because I have a Insert Exec statement inside my stored procedure...

Is there any way to come over this issue ?

syntax of my code...

create table #Temp1 (ID int)

insert into #Temp1
EXEC SP1

when I try to run the above code I get the error "Insert exec cannot be nested"

SP syntax :

Create Procedure SP1
as
Begin
create table #Temp2
statements.....

Insert into #temp2
exec SP<Name>

staments.. cont...
END

View 1 Replies View Related

How To Store The Output Of Stored Procedure To A Temp Table

Jan 28, 2008

Hi all,

I've a requirement to store the output of the stored procedure into temp. tables/ table varibles.
I've 4 select statements as my output of the stored procedure. How do I store the results of all the 4 select stmnts into 4 different temp tables.

Simplified SP is as...


Create procedure usp_test
as
begin

select c1,c2 from table1
select c3,4 from table2
select c9,c8 from table3
select c5,c7 from Table4
end

I'm expecting something like this...

declare @table1 table (c1, c2)
insert into @table1
Exec <Sp_Name>

select * from @table1

I know the above stmnt works, if my SP has only 1 select stmnt as output.
Please help me to acheive this for multiple select statements.

Thanks,

View 5 Replies View Related

Transact SQL :: How To Store Result Of Exec Command Into Temp Table

Apr 7, 2013

I wanted to insert the result-set of a Exec(@sqlcommand) into a temp table. I can do that by using:

Insert into #temp
Exec(@sqlcommand)

For this to accomplish we need to define the table structure in advance. But am preparing a dynamic-sql command and storing that in variable @sqlcommand and the output changes for each query execution. So my question is how to insert/capture the result-set of Exec(@sqlcommand) into a temp table when we don't know the table structure.

View 17 Replies View Related

RS2005: Export To Excel Error: Destination Array Was Not Long Enough. Check DestIndex And Length, And The Array's Lower Bounds.

Jan 25, 2007

All,

I am using Reporting Services 2005. One of my reports is getting the following error when I try to export to Excel. It will export to .CSV though.

"Destination array was not long enough. Check destIndex and length, and the array's lower bounds."

Any suggestions would be greatly appreciated. Please copy me at machelle.a.chandler@intel.com.

Machelle

View 10 Replies View Related

How Would I Send A String Array As A Integer Array?

Jun 25, 2007

I have a stored procedure that has a paramter that accepts a string of values. At the user interface, I use a StringBuilder to concatenate the values (2,4,34,35,etc.) I would send these value to the stored procedure. The problem is that the stored procedure doesn't allow it to be query with the parameter because the Fieldname, "Officer_UID" is an integer data type, which can't be query against parameter string type.
What would I need to do to convert it to an Integer array?
@OfficerIDs as varchar(200) 
Select Officer_UID From Officers Where Officer_UID in (@OfficerIDs)
 Thanks

View 5 Replies View Related

Convert Table Data Into Array Or Maybe Something Else?!?

Apr 27, 2008

I am using vs2008 with c#.I have table in my database that has email addresses stored in a column.  I would like somehow to take each email address from every row and paste them into a textbox that can be copied and pasted with a comma delimiter into outlook so I can send a mass email.I have no idea how I can accomplish this task. 

View 3 Replies View Related

Array Data Type In SQL Server 2005

Aug 9, 2006

Hi,

I was migrating from Oracle to SQL Server 2005 using SSMA (SQL Server Migration Assistant) but i`ve found an issue, i can´t find how to fix it. In my stored procedure in PL/SQL exists this lines:

TYPE T_ARRAY_COL IS VARRAY (1000 ) OF VARCHAR2 (50);
A_COLUMNS T_ARRAY_COL := T_ARRAY_COL();

Somebody know how can i simulate this data type ARRAY. I was reading http://msdn.microsoft.com/msdnmag/issues/04/02/TSQLinYukon/ but some things are not clear for me.... please help me, give me one hand.

Thank you

David



View 1 Replies View Related

Parse Array Data Type To Rows

Jun 7, 2007

Hi,



We're importing data from a progress db. Some of the columns contain arrays or delimited values which represent accounting periods.



Currently I'm passing the arrays row by row to a stored procedure which parses and inserts each value as a row for the applicable accounting period, it works but is very slow.



Any Ideas?



Thanks



Emilio

View 6 Replies View Related

Creating A Stored Procedure That Will Summarize Data In A Table Into A Table Reflecting Period Data Using An Array Type Field

Sep 20, 2007

I am attempting to create a stored procedure that will launch at report runtime to summarize data in a table into a table that will reflect period data using an array type field. I know how to execute one line but I am not sure how to run the script so that it not only summarizes the data below but also creates and drops the table.

Any help would be greatly appreciated.

Current Table

Project | Task | Category | Fiscal Year | Fiscal Month | Total Hours
---------------------------------------------------------------------------------------------------------
Proj 1 | Task 1 | Cat 1 | 2007 | 01 | 40
Proj 1 | Task 1 | Cat 2 | 2007 | 02 | 20
Proj 1 | Task 1 | Cat 3 | 2007 | 03 | 35
Proj 1 | Task 1 | Cat 1 | 2008 | 01 | 40
Proj 1 | Task 1 | Cat 2 | 2008 | 02 | 40
Proj 1 | Task 1 | Cat 3 | 2008 | 03 | 40

Proposed Table

Project | Task | Category | Fiscal Month 01 | Fiscal Month 02 | Fiscal Month 03 | Fiscal Year
---------------------------------------------------------------------------------------------------------------------------------------------------
Proj 1 | Task 1 | Cat 1 | 40 | 0 | 0 | 2007
Proj 1 | Task 1 | Cat 2 | 0 | 20 | 0 | 2007Proj 1 | Task 1 | Cat 3 | 0 | 0 | 35 | 2007
Proj 1 | Task 1 | Cat 1 | 40 | 0 | 0 | 2008

Proj 1 | Task 1 | Cat 2 | 0 | 40 | 0 | 2008
Proj 1 | Task 1 | Cat 3 | 0 | 0 | 40 | 2008

Thanks,
Mike Misera

View 6 Replies View Related

Array Data Type In SQL Server Stored Procedures?

Aug 17, 2000

Is there any array data type in SQL Server 7.0. I am using VB 6.0 with ADO 2.1. I am populating a MSFlexGrid with values that I pass to SQL Server one at a time and insert into the database. What I would like to do is pass the entire contents of the Grid at once to a stored procedure and let SQL do the processing so my routine is not going back and forth to the client. I did not find any documentation on any array data types in SQL. What is my best approach to this problem?
Thanks,
Dan Collins

View 6 Replies View Related

Data Access :: How To Load Data From CSV File In Temp Table At Run Time

May 28, 2015

how I can load the CSV file data into the sql server table. I know there are ways like bulk insert and other to load the csv file data into the table. But in my case the table doesn't exist and has to be created at the run time. With simple insert in temp table we do like select * into #temp from tablename and that creates the temp table. So. I need something like that which create the temp table and load the data into it. because the CSV file would have different number of columns and names so I can not create the table structure in advance. I have to create the table at run time. 

View 3 Replies View Related

Asp.net Page Is Unable To Retrieve The Right Data Calling The Store Procedure From The Dataset/data Adapter

Apr 11, 2007

I'm trying to figure this out
 I have a store procedure that return the userId if a user exists in my table, return 0 otherwise
------------------------------------------------------------------------
 Create Procedure spUpdatePasswordByUserId
@userName varchar(20),
@password varchar(20)
AS
Begin
Declare @userId int
Select @userId = (Select userId from userInfo Where userName = @userName and password = @password)
if (@userId > 0)
return @userId
else
return 0
------------------------------------------------------------------
I create a function called UpdatePasswordByUserId in my dataset with the above stored procedure that returns a scalar value. When I preview the data from the table adapter in my dataset, it spits out the right value.
But when I call this UpdatepasswordByUserId from an asp.net page, it returns null/blank/0
 passport.UserInfoTableAdapters oUserInfo = new UserInfoTableAdapters();
Response.Write("userId: " + oUserInfo.UpdatePasswordByUserId(txtUserName.text, txtPassword.text) );
 Do you guys have any idea why?
 
 

View 6 Replies View Related

A Curious Error Message, Local Temp Vs. Global Temp Tables?!?!?

Nov 17, 2004

Hi all,

Looking at BOL for temp tables help, I discover that a local temp table (I want to only have life within my stored proc) SHOULD be visible to all (child) stored procs called by the papa stored proc.

However, the following code works just peachy when I use a GLOBAL temp table (i.e., ##MyTempTbl) but fails when I use a local temp table (i.e., #MyTempTable). Through trial and error, and careful weeding efforts, I know that the error I get on the local version is coming from the xp_sendmail call. The error I get is: ODBC error 208 (42S02) Invalid object name '#MyTempTbl'.

Here is the code that works:SET NOCOUNT ON

CREATE TABLE ##MyTempTbl (SeqNo int identity, MyWords varchar(1000))
INSERT ##MyTempTbl values ('Put your long message here.')
INSERT ##MyTempTbl values ('Put your second long message here.')
INSERT ##MyTempTbl values ('put your really, really LONG message (yeah, every guy says his message is the longest...whatever!')
DECLARE @cmd varchar(256)
DECLARE @LargestEventSize int
DECLARE @Width int, @Msg varchar(128)
SELECT @LargestEventSize = Max(Len(MyWords))
FROM ##MyTempTbl

SET @cmd = 'SELECT Cast(MyWords AS varchar(' +
CONVERT(varchar(5), @LargestEventSize) +
')) FROM ##MyTempTbl order by SeqNo'
SET @Width = @LargestEventSize + 1
SET @Msg = 'Here is the junk you asked about' + CHAR(13) + '----------------------------'
EXECUTE Master.dbo.xp_sendmail
'YoMama@WhoKnows.com',
@query = @cmd,
@no_header= 'TRUE',
@width = @Width,
@dbuse = 'MyDB',
@subject='none of your darn business',
@message= @Msg
DROP TABLE ##MyTempTbl

The only thing I change to make it fail is the table name, change it from ##MyTempTbl to #MyTempTbl, and it dashes the email hopes of the stored procedure upon the jagged rocks of electronic despair.

Any insight anyone? Or is BOL just full of...well..."stuff"?

View 2 Replies View Related

BCP Data From Temp Table

Feb 8, 2000

I am having trouble getting data from a temporary table into a asci text file. How would I go about doing that using bcp, dts, or bulk insert?

View 1 Replies View Related

Temp Table Data

Nov 5, 2007

Is it possible to look at the entries in a temporary table when stepping through a procedure?

View 1 Replies View Related

Translating Data Into Temp Table

Sep 29, 2004

Hi all

I have this snippet of data

hierId nodeId nodeName parentId childId
----------- ----------- -------------------------------------- ----------- -----------
437 1582275 Accountants 1582270 1582275
437 1582276 Asset financiers 1582270 1582276
437 1582270 Banking & financial institutions NULL NULL
437 1582286 Private banks 1582277 1582286
437 1582277 Banks 1582270 1582277


I want to loop through this data and put the results into a temp table so it looks like this:


hierId nodeName ids
------------------------------------------------------------------------------------------------------
437 Banking & financial institutions -> Accountants1582270 | 1582275
437Banking & financial institutions -> Asset financiers1582270 | 1582276
437Banking & financial institutions -> Banks1582270 | 1582277
437Banking & financial institutions -> Banks -> Private banks1582270 | 1582277 | 1582286
437Banking & financial institutions1582270


Can anyone help me with achieving this

Thanks in advance

View 2 Replies View Related

Select Data From #temp Table In SQL

Apr 6, 2004

I am building a dynamic query stored procedure. I am first filling a temp table with data:

Declare
@Counter int

drop table #tempmerge
create table #tempmerge(IDIndex int IDENTITY, CitationNum char(9),Exp1 int)

insert into #tempmerge
Select E_Cit_For_Merge, Count(*) as Exp1
from dbo.E_Citation_XML_Data
group by E_Cit_For_Merge
having Count(*)>1
select * from #tempmerge

Results returned from #tempmerge table:

IDIndex CitationNum Exp1
----------- ----------- -----------
1 4AA020621 2
2 4AA022361 2
3 4AA022391 2
4 4AA022423 2
5 4AA022532 3
6 4AA027761 2
7 4AA030513 2

Then, I want to use a while loop, looping thru the #tempmerge table
and retrieving the CitationNum value of each row:

set @RowCount = (Select Count(*) from #tempmerge)
set @Counter = 1
While @Counter <= @RowCount
Begin

Set @WhereStatement2 = ' where E_Cit_For_Merge= (Select CitationNum from #tempmerge
where IDIndex = @Counter)'

E_Cit_For_Merge is a field in a SQL table.
I Declare @Counter as int.

I get the Error message that:

FROM E_Citation_XML_Data where E_Cit_For_Merge= (Select CitationNum from #tempmerge
where IDIndex = @Counter)

Server: Msg 137, Level 15, State 2, Line 24
Must declare the variable '@Counter'.

Any Suggestions?
Thanks
JEB

View 6 Replies View Related

Temp Table Loses Data

Sep 26, 2007

Not sure if you can help on this but Ive got a stored procedure in sql server and it creates a temp table. I then call another stored procedure from this one. When it returns to the 1st stored procedure I want the temp table to keep the information entered into the table, but the data is lost.

Is there a flag that can be turned on and off do this?

Or can you suggest anything else

Regards

Steve

Steve Fouracre

View 6 Replies View Related

Temp Table In Data Flow

Mar 28, 2006

is it possible to retrieve data from a #temp table in flow control task? or create a temp table perhaps?

or what if i create a table in the control flow using sql execute task and inside the data flow access that table, is that possible?

View 1 Replies View Related

Manipulate Data Without Using Temp Tables?

Dec 5, 2007

Good morning, everyone. Maybe I'm just having a brain fart, but I'm totally new to SSIS (I dabbled very little with DTS in the 2000 days) and cannot for the love of me figure out how to achieve my goal with it:

My company needs to extract data from a variety of sources; tab-delim files, Access databases, other SQL tables and the like. I know how to do this. However, I need to perform data manipulation queries on this data before I place them into SQL tables, as I want to avoid having umpteen temporary tables that I'll need to add checking for. My predecessor did everything in Access, and has a 76-step process (yikes!) that basically will grab all the data, do some minor manipulation, and plop it into a temp table (this is still in Access, not SQL), then repeat the same thing dozens of times.

To give you an example, here's a sample of what I want to do:

- Extract several columns of data from a tab-delimited file on the local drive. This I know how to do already.
- Perform some data cleanup and manipulation functions on this data (specifically, obtain the lowest value out of three columns, with the added caveat that I make sure it's not zero to begin with). I have the SQL code for this already written.
- Store the results of this data somewhere, so I can pull it and apply additional logic to it; for example, take the lowest value I've retrieved, and update the corresponding column in another database table with it.

Basically, is there any way to avoid the use of dozens of temp tables? There's a lot of data which needs to be pulled in, manipulated, and spit back out to be manipulated by something else a little later on, and the way my predecessor did it was, as I said, to use dozens of Access "Make Table" queries for every minor thing. It's not a big deal if I need to do it, just I'm trying to consolidate the steps needed, as the old way is very inefficient. I've been at this job a month and I'm still trying to wade through all of his queries to discover just what they do, and look into combining several of them.

Forgive the slightly newbish question, but as I stated I've not worked with SSIS really. I'm in the process of learning it better, as I'm sure it can fit our needs.

View 5 Replies View Related

How Can I Store Data ?(encoding And Data Type)

Oct 20, 2007

hi my friends;i have got a problem.i thing you can help mea='x80x02}qx00(Kx02Kx03Kx04Kx06Kx05Kx07u. 'i want to store database but i don't know which encoding and dataytpepls help mesorry for my bed english...thanks all

View 3 Replies View Related

Selecting Data From A Temp Table In A SP -- Very Urgent

Sep 25, 2007

Hello. I have a SP. I am passing two variables to it that are comma seperated lists (ids) so that I can use an IN clause. But since I cannot use these CSV in an IN clause directly I wrote a temp table that first parses the CS list and creates a temp table with a single column of IDS.Then in a second temp table I am selecting the data using enrollment_id IN (Select enrollment_id From #temptable)Then the SP selects data from the second temp table.This works exactly the way it is supposed to work. But when I call the SP from ASP.NET it doesn't return any data. I just cant seem to return data by selecting from a temp table. And my ASP.NET code is correct because I commented out everything and just returned the parameters I was passing and that worked. So does anyone know how to select data from a temp table in a SP when executed from ASP.NET?I even tried Table Variables and same thing. It works great in SQL but when called from ASP.NET it doesnt return any data. I am guessing it's probably losing its scope. Any quick help would be appreciated. Thank you.Here is a snippet of the SP (even this fails):CREATE PROCEDURE [dbo].[returnEnrollments](@organization_id int, @test_item_list ntext, @enrollment_list ntext)As--select  @test_item_list as tilist, @enrollment_list as elistDeclare @report_start_date datetime;Declare @report_end_date datetime;Declare @test_item_id_list varchar(8000);Declare @enrollment_id_list varchar(8000);DECLARE @TestItemID varchar(10), @Pos intDECLARE @EnrollmentID varchar(10)--Set @IDList = @test_item_id_list;--Set @EnrollmentIDList = @enrollment_id_list;Set @test_item_id_list = Cast(@test_item_list As varchar(8000))Set @enrollment_id_list = Cast(@enrollment_list As varchar(8000))Select @report_start_date = report_start_date, @report_end_date = report_end_date From organization Where organization_id = @organization_id;-- Create a temp table to store all the enrollment idsIF OBJECT_ID('tempdb..#EnrollTemp') IS NOT NULLDROP TABLE #EnrollTempCREATE TABLE #EnrollTemp (enrollment_id int NOT NULL)SET @enrollment_id_list = LTRIM(RTRIM(@enrollment_id_list))+ ','SET @Pos = CHARINDEX(',', @enrollment_id_list, 1)IF REPLACE(@enrollment_id_list, ',', '') <> ''BEGIN    WHILE @Pos > 0    BEGIN        SET @EnrollmentID = LTRIM(RTRIM(LEFT(@enrollment_id_list, @Pos - 1)))        IF @EnrollmentID <> '' And @EnrollmentID > 0        BEGIN            INSERT INTO #EnrollTemp (enrollment_id) VALUES (CAST(@EnrollmentID AS int)) --Use Appropriate conversion        END        SET @enrollment_id_list = RIGHT(@enrollment_id_list, LEN(@enrollment_id_list) - @Pos)        SET @Pos = CHARINDEX(',', @enrollment_id_list, 1)    ENDENDSelect top 20 * From #EnrollTemp  Edit: Just used a DataReader instead of a datatable and it works. Dont know why it would fail with a datatable. 

View 4 Replies View Related







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