Author |
Topic |
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 11:04:34
|
Hi,I need to create SP that will create new table (temporary if possible),table something like this...CREATE TABLE odgovori ( [P_id] [int] NOT NULL , [T_Odg] [text] NOT NULL , [Odg] [txt] NOT NULL , )I'am new in this,so if anyone can help me it would be nice...thx |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-05 : 12:26:18
|
Why should this be done by using a SP?And a temp table is session based you cannot use it everywhere. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 12:51:22
|
because I don't need that table whole time, I need her to be deleted when exit aplication and created again when entering aplication...can it be done? or I need some other solution? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-05 : 12:55:43
|
I can imagine that an application is always connecting, disconnecting and reconnecting during the runtime of that application. So an temp table is not an option.To think about another solution we should know why this table is needed. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 13:06:23
|
that should be desktop aplication for testing students... so in that table i would place their answers so i can compare their answers with correct ones...so when student logon->table i created,and when he exits->table deleted (is that make any sense?) |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-05 : 13:17:19
|
You can have a permanent table on your server/DB and store the answers with a student_id among all other answers from other students.You can also delete the answers by using the student_id. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 13:25:30
|
can you give me example code,not shore what u mean...so i have "permanent" table,and when they(students) exit aplication i need to delete inputs where (for example) stud_id = 1? something like that? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-05 : 13:33:58
|
Yes that's what I mean.Instead of dropping the temp table you can delete the answers that you don't need any longer.That implies each student (i.e. his application) has an ID that is unique to other students.And I would add a datetime column to the table that can hold the date when the answer was inserted. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 13:38:58
|
ok...thy for your help |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-05 : 13:41:29
|
welcome No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 13:45:07
|
one more question...how can I take one column from one table and insert it into another? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-05 : 13:57:46
|
Could you be more specific?Do you want to update an existing record or insert a new record?Are the two tables related by a key column?An example would be great! No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 14:03:19
|
table: studentsStud_idindexFnameLnametable: results(i need that "index or Stud_id" here)pointssomething like this |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-05 : 14:08:06
|
I think you are talking about that column and not its value right?First you need to know the datatype of column Stud_id - I think it is an INT.To have that column in table results you can do this:alter table result add Stud_id int nullIs it what you want? No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-05 : 15:17:55
|
i need that IDs(values) in that other table so i can join points to right student |
|
|
socox
Starting Member
13 Posts |
Posted - 2009-09-06 : 15:36:02
|
and how can I take "index" of a student taht is loged on at that time and put it in that table with his answers? |
|
|
|