| Author |
Topic |
|
pinoyextacy
Starting Member
15 Posts |
Posted - 2008-07-21 : 13:16:41
|
| I created a scriptselect ltrim(rtrim(cast(clt_id as varchar(10)))) + ltrim(rtrim(convert(char, cast(clt_ref_no as varchar(10))))) as account, max(list_date) as max_list_date, status_code from dm.debtwhere clt_id like 'wsp%' and status_code='520'group by clt_ref_no, clt_id, status_codeorder by clt_ref_no descand it outputsaccount max_list_date status_code105R5681 2006-01-15 110105P8541 2006-02-04 110I want to create and store this data in a temporary table so I can match it with an existing table. However, I want the fields account and max_list_date created because they are just being derived from combine fields and I believe they might be labels only.I was looking at using the command to create view [name of table] as but I don't know if that will work. |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-07-21 : 13:18:17
|
| select ltrim(rtrim(cast(clt_id as varchar(10)))) + ltrim(rtrim(convert(char, cast(clt_ref_no as varchar(10))))) as account, max(list_date) as max_list_date, status_code INTO MY_TEMP_TABLEfrom dm.debtwhere clt_id like 'wsp%' and status_code='520'group by clt_ref_no, clt_id, status_codeorder by clt_ref_no desc |
 |
|
|
pinoyextacy
Starting Member
15 Posts |
Posted - 2008-07-21 : 14:17:14
|
| I am getting a variable 'my_temp_table' not found error |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-21 : 14:22:58
|
quote: Originally posted by pinoyextacy I am getting a variable 'my_temp_table' not found error
that was for demonstration purpose.replace it with your temporary table name and remember to precede by #select ltrim(rtrim(cast(clt_id as varchar(10)))) + ltrim(rtrim(convert(char, cast(clt_ref_no as varchar(10))))) as account, max(list_date) as max_list_date, status_code INTO #YourTemporaryTableNameHerefrom dm.debtwhere clt_id like 'wsp%' and status_code='520'group by clt_ref_no, clt_id, status_codeorder by clt_ref_no desc |
 |
|
|
pinoyextacy
Starting Member
15 Posts |
Posted - 2008-07-21 : 14:30:36
|
| it executed but now I don't know how to access it or where it is |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-21 : 14:33:38
|
quote: Originally posted by pinoyextacy it executed but now I don't know how to access it or where it is
select ltrim(rtrim(cast(clt_id as varchar(10)))) + ltrim(rtrim(convert(char, cast(clt_ref_no as varchar(10))))) as account, max(list_date) as max_list_date, status_code INTO #YourTemporaryTableNameHerefrom dm.debtwhere clt_id like 'wsp%' and status_code='520'group by clt_ref_no, clt_id, status_codeorder by clt_ref_no descselect * from #YourTemporaryTableNameHere Please note that this table will be available only for the current connection. |
 |
|
|
pinoyextacy
Starting Member
15 Posts |
Posted - 2008-07-21 : 14:50:01
|
| THAT WORKS THANKS |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-07-21 : 15:49:29
|
quote: Originally posted by visakh16 that was for demonstration purpose.replace it with your temporary table name and remember to precede by #
no...It should have created a table |
 |
|
|
pinoyextacy
Starting Member
15 Posts |
Posted - 2008-07-21 : 16:38:32
|
| Now, how do you process two temporary tables on the same connection in which it pops two screens |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|