Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Displaying using temp tables

Author  Topic 

sonia
Starting Member

1 Post

Posted - 2003-03-12 : 04:39:07
Hi
I have a table which contains some audit data based some insertion,updation and deletion.

for eg. Aud_rec table contains.

tab_name varchar(20),activity varchar(20),affected_col varchar(20),old_value varchar(20) new_value varchar(20)

I have to read the data present in this table and present it in a
understandable way to some managers table wise.

So, in my STORED PROC, i am planning to create a temporary table whose column names will be distinct entries from
affected_col of the aud_rec table + few other colums.

So first thing is,
1.For this, should i create a Temporary table. or is there any other option in sql server.
2.Is it advisable to go for a cursor to get the values from affected_col from the aud_rec table or can it be stored and fetched from an array.

Pls do help me, as i am new to SQL server

regards
sonia

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-03-12 : 06:51:36
Sonia, you need to have a clearer goal before you decide on the implementation. I think your first step should be to define the "understandable way" you want to report on the data.

Post some sample data and the rowset you would like to generate with your query. Then figure out how to write the query to do that.

(FYI, when posting to a board such as this, it is always a good idea to describe the table(s) you are working with. You did this, but the best way to do it is with a working create table, so that someone who is offering to help with your problem can cut&paste and quickly create your tables to work with.)

Jay White
{0}
Go to Top of Page

samsekar
Constraint Violating Yak Guru

437 Posts

Posted - 2003-03-12 : 07:39:38
If you are only going to take distinct values from the table for reports then DISTINCT clause will itself do. Otherwise please mention how your reports would be for a set of sample data. Somebody can help you.

create table test (tab_name varchar(20),activity varchar(20),affected_col varchar(20),
old_value varchar(20), new_value varchar(20))
insert into test values ('tabname1', 'activity1', 'aff1', 'old1','new1')
insert into test values ('tabname1', 'activity1', 'aff1', 'old2','new2')
insert into test values ('tabname1', 'activity1', 'aff1', 'old1','new1')

select distinct tab_name, activity, affected_col, old_value, new_value from test

___________________________________________________________________________
Success is not a destination that you ever reach. Success is the quality of your journey.


Edited by - samsekar on 03/12/2003 07:40:51
Go to Top of Page
   

- Advertisement -