473,772 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create temporary table through select statement

Hi,

I want to create a temporary table and store the logdetails from
a.logdetail column.

select a.logdetail , b.shmacno
case when b.shmacno is null then
select
cast(substring( a.logdetail,1,c harindex('·',a. logdetail)-1) as
char(2)) as ShmCoy,
cast(substring( a.logdetail,cha rindex('·',a.lo gdetail)+1,char index('·',a.log detail,charinde x('·',a.logdeta il)+1)-(charindex('·', a.logdetail)+1) )
as char(10)) as ShmAcno
into ##tblabc
end
from shractivitylog a
left outer join
shrsharemaster b
on a.logkey = b.shmrecid

This statement giving me syntax error. Please help me..

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'case'.
Server: Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'end'.

sample data in a.logdetail

BR··Light Blue Duck··Toon Town Central·Silly Street···02 Sep
2003·1·SGL·SGL· ·01 Jan 1900·0·0·0·0·0. 00·····
·0234578······· ····· ··········
UB··Aqua Duck··Toon Town Central·Punchli ne Place···02 Sep
2003·1·SGL·SGL· ·01 Jan 1900·0·0·0·0·0. 00·····
Regards.
Jul 20 '05 #1
2 20534
1. You need a "," before CASE.
2. Put your subqueries inside parentheses.
3. Your CASE expression is returning multiple values.
4. You can't use a SELECT INTO inside another SELECT statement.

Sorry with all there problems I can't rewrite your script, I'm not
sure what you want to do. Tell us what you are looking for and send
the DDL.

Shervin

ki***@boardroom limited.com (Omavlana) wrote in message news:<b1******* *************** ****@posting.go ogle.com>...
Hi,

I want to create a temporary table and store the logdetails from
a.logdetail column.

select a.logdetail , b.shmacno
case when b.shmacno is null then
select
cast(substring( a.logdetail,1,c harindex('·',a. logdetail)-1) as
char(2)) as ShmCoy,
cast(substring( a.logdetail,cha rindex('·',a.lo gdetail)+1,char index('·',a.log detail,charinde x('·',a.logdeta il)+1)-(charindex('·', a.logdetail)+1) )
as char(10)) as ShmAcno
into ##tblabc
end
from shractivitylog a
left outer join
shrsharemaster b
on a.logkey = b.shmrecid

This statement giving me syntax error. Please help me..

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'case'.
Server: Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'end'.

sample data in a.logdetail

BR··Light Blue Duck··Toon Town Central·Silly Street···02 Sep
2003·1·SGL·SGL· ·01 Jan 1900·0·0·0·0·0. 00·····
·0234578······· ····· ··········
UB··Aqua Duck··Toon Town Central·Punchli ne Place···02 Sep
2003·1·SGL·SGL· ·01 Jan 1900·0·0·0·0·0. 00·····
Regards.

Jul 20 '05 #2
Hi,

You can't create a temp table with CASE function; try with this:

select a.logdetail , case when b.shmacno is null then
cast(substring( a.logdetail,1,c harindex('·',a. logdetail)-1) as
char(2))+
cast(substring( a.logdetail,cha rindex('·',a.lo gdetail)+1,char index('·',a.log detail,charinde x('·',a.logdeta il)+1)-(charindex('·', a.logdetail)+1) )
as char(10))
end
into ##tblabc -- optional
from shractivitylog a
left outer join
shrsharemaster b
on a.logkey = b.shmrecid

Bye

ki***@boardroom limited.com (Omavlana) wrote in message news:<b1******* *************** ****@posting.go ogle.com>...
Hi,

I want to create a temporary table and store the logdetails from
a.logdetail column.

select a.logdetail , b.shmacno
case when b.shmacno is null then
select
cast(substring( a.logdetail,1,c harindex('·',a. logdetail)-1) as
char(2)) as ShmCoy,
cast(substring( a.logdetail,cha rindex('·',a.lo gdetail)+1,char index('·',a.log detail,charinde x('·',a.logdeta il)+1)-(charindex('·', a.logdetail)+1) )
as char(10)) as ShmAcno
into ##tblabc
end
from shractivitylog a
left outer join
shrsharemaster b
on a.logkey = b.shmrecid

This statement giving me syntax error. Please help me..

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'case'.
Server: Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'end'.

sample data in a.logdetail

BR··Light Blue Duck··Toon Town Central·Silly Street···02 Sep
2003·1·SGL·SGL· ·01 Jan 1900·0·0·0·0·0. 00·····
·0234578······· ····· ··········
UB··Aqua Duck··Toon Town Central·Punchli ne Place···02 Sep
2003·1·SGL·SGL· ·01 Jan 1900·0·0·0·0·0. 00·····
Regards.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8418
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: '@localhost' to database 'test1' Any help would be appreciated
0
2738
by: Russell R Snella | last post by:
------=_NextPart_000_0000_01C35111.935D6050 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, Mysql Version 4.0.11a-gamma When I try and run the following query
2
2585
by: Thomas T. Thai | last post by:
I would like to select a random record from a group of records so I'd end up with one random record per group: CREATE TABLE randtest ( catnum int, title varchar(32) ); INSERT INTO randtest VALUES (1, 'one.one'); INSERT INTO randtest VALUES (1, 'one.two');
0
2813
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: existing SQL declare temporary table insert in temporary table
2
4325
by: Phil Endecott | last post by:
Dear PostgreSQL experts, I have encountered a problem with temporary tables inside plpgsql functions. I suspect that this is a known issue; if someone could confirm and suggest a workaround I'd be grateful. My function creates a couple of temporary tables, uses them, and drops them before returning:
1
2582
by: Thomas F.O'Connell | last post by:
Is the ON COMMIT syntax available to temporary tables created using the CREATE TABLE AS syntax? If not, is there a way to drop such a table at the end of a transaction? -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC
0
1940
by: mktilu | last post by:
hi can any one give me a example to create temporary table in Stored procedure during run time and then delete the temporary table at the end of the stored procedure .its argent
0
1716
by: Franck | last post by:
Hi, Got some problems from reading temporary table I'm creating in my Sql Server 2005 Database from Access 2K3 through ODBC. I can create it successfully but can't find a way to query it ! The code below (the select part) returns me Microsoft Jet Engine Error that tells me it can't find the object. Any help would be most welcome !!
1
5316
by: mpramodk | last post by:
Please find the code for creating a temporary table and access it in UDF functions. While we do this we obtain a compile time error stating "A declared temporary table cannot be used in the given context." CODE: DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP (id INT, data VARCHAR(10)) ON COMMIT PRESERVE ROWS; ----------------------------- Commands Entered ------------------------------
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.