473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

temporary table

i created a temporary table like this

SqlStr = "CREATE TABLE #t_temp(MemberID int, First_Name varchar, Last_Name varchar, Introducedby int)"

inserted values id,firstname,lastname and x_intro(is the count)

SqlStr = "INSERT MemberID, First_Name,Last_Name from Membership AND x_intro INTO #t_temp where Introducedby = " &x_introAgent

i have to get the output order by first name.

StrSql4 ="SELECT * from #t_temp ORDER BY First_Name"
Set rsAgents2 = Server.CreateObject("ADODB.Recordset")
rsAgents2.Open StrSql4, conn, 1, 2

its not working
can u help me?
Feb 9 '08 #1
2 1623
shweta123
692 Expert 512MB
Hi,

Can you please specify about the error you are getting. Please check the syntax of your sql statement :

SqlStr = "INSERT MemberID, First_Name,Last_Name from Membership AND x_intro INTO #t_temp where Introducedby = " &x_introAgent

It should be as following :

INSERT INTO #t_temp(MemberID, First_Name,Last_Name)
SELECT MemberID, First_Name,Last_Name
FROM Membership
WHERE Introducedby = " &x_introAgent



i created a temporary table like this

SqlStr = "CREATE TABLE #t_temp(MemberID int, First_Name varchar, Last_Name varchar, Introducedby int)"

inserted values id,firstname,lastname and x_intro(is the count)

SqlStr = "INSERT MemberID, First_Name,Last_Name from Membership AND x_intro INTO #t_temp where Introducedby = " &x_introAgent

i have to get the output order by first name.

StrSql4 ="SELECT * from #t_temp ORDER BY First_Name"
Set rsAgents2 = Server.CreateObject("ADODB.Recordset")
rsAgents2.Open StrSql4, conn, 1, 2

its not working
can u help me?
Feb 10 '08 #2
hi,

From a table i displayed the Agents memberid, firstname,lastname & total introduced(no of members each Agent introduced)
the code is as follows..

StrSql = "SELECT MemberID,First_Name,Last_Name,Introducedby FROM Membership where IsAgent = 1"
Set rsAgents = Server.CreateObject("ADODB.Recordset")
rsAgents.Open StrSql, conn, 1, 2
rsAgents.Movefirst

Do until (rsAgents.Eof )
x_introAgent = rsAgents("MemberID")
StrSql2 ="SELECT First_Name from Membership where Introducedby = " &x_introAgent
Set rsAgents1 = Server.CreateObject("ADODB.Recordset")
rsAgents1.Open StrSql2, conn, 1, 2
x_intro = rsAgents1.recordcount
rsAgents.Movenext


I got the output in the order in which they are entered into the table.. But i want the output order by First_Name. So i created a temporary table like this

SqlStr = "create table #t_temp(MemberID int, First_Name varchar, Last_Name varchar, Introducedby int)"


Then i inserted into temporary table as follows..
If x_intro > 0 then
SqlStr = "INSERT INTO #t_temp(MemberID, First_Name, Last_Name, Introducedby) Values (select MemberID, First_Name,Last_Name from Membership) & x_intro where Introducedby = " &x_introAgent
End if


then i displayed from temporary table as follows..
SqlStr3 = "SELECT * FROM #t_temp order by First_Name"
Set rsAgents2 = Server.CreateObject("ADODB.Recordset")
rsAgents2.Open SqlStr3, conn, 1, 2

I am extremely new to asp & i am creating temporary table for the first time. I don't know whether the syntax is correct or not. After the select statement should i write the drop table statement?

During output the values are retrieved from the original table not from the temporary table. i want the values from the temporary table order by first name

Hope u understand it
Can u please help me?
Feb 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Corrine | last post by:
Hi, I am creating a global temporary table that is session-specific. I insert a BLOB into this table, and then select the BLOB from this table into a ResultSet. The ResultSet sees this BLOB...
5
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. ...
0
by: Didier ROS | last post by:
Hi, I am a newbie I want to create a temporary table and I get the following error message : mysql> CREATE TEMPORARY TABLE tempemp AS SELECT * FROM emp; ERROR 1044: Access denied for user:...
4
by: gonzal | last post by:
Hi Dose any body know why a temporary table gets deleted after querying it the first time (using SELECT INTO)? When I run the code bellow I'm getting an error message when open the temp table...
11
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the...
0
by: nedbollard | last post by:
Hi, Having checked out a declared (rather than created) temporary table successfully in SPUFI, I have hit a problem in running the same SQL in the cobol prog I am ameding to use it. I have:...
4
by: prasad | last post by:
I am getting sql error during binding a program which access a temporary table. The temporary table declaration and access methods are given below. EXEC SQL DECLARE GLOBAL TEMPORARY TABLE TEM88...
7
by: Larry | last post by:
Hi, I have unbelievable problems just to save a record! I make an input to a record in a subform, which has a temporary table as its recordsource. When I am done, and want to save the...
5
by: Adam W. Saxton | last post by:
We have a few existing stored procedures which create a Global Temporary Table (##), do some work on the table and then delete the table. The issue we have is that if our Server application is...
1
by: Kburton | last post by:
All, I am trying to declare a cursor on global temporary table. I declared the global temporary table first and then the cursor but I got the following error: 42601(-104) SQL0104N An...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.