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.
| Author |
Topic |
|
Manoool
Starting Member
6 Posts |
Posted - 2007-11-12 : 10:29:15
|
| Hi.....I have problem and I need your help I stored a procedure in the Projects Folder in my computerand I want to return the procedure result in a column inside tableHow I can do that????????? thank you |
|
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-12 : 10:30:50
|
| is the procedure result a single value? |
 |
|
|
Manoool
Starting Member
6 Posts |
Posted - 2007-11-12 : 11:31:31
|
| this is the procedurecreate proc makeTestKey(@courseNumber int) asbegininsert into test(a2) values(right( replicate('0', 7) + convert(char(6), convert(int, Year(GetDate()) % 2000 * 10000 + @courseNumber)), 7))endwhere the courseNumber is column in the test tableand I want the result to be store back in the column a2 in the same table but I do't how to do this and I hope to help me |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-11-12 : 11:39:46
|
CourseNumber is a column name in your destination table? and you want column a2 to be updated with that..WHat you are asking doesn't make a whole lot of practical sense, but to update column a2 with the formula Update [TestTable]Set a2 = right( replicate('0', 7) + cast(Year(GetDate()) % 2000 * 10000 + @courseNumber as varchar), 7)) Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
Manoool
Starting Member
6 Posts |
Posted - 2007-11-12 : 13:10:44
|
| but ,where should I put this formula????????Update [TestTable]Set a2 = right( replicate('0', 7) + cast(Year(GetDate()) % 2000 * 10000 + @courseNumber as varchar), 7))in query???? or formula property????and if I should put it in query,how can I call this query such thateach time I enter data in the test table the a2 column will contain this value????????please help me because I lost the hope to solve it.....thank |
 |
|
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-12 : 13:39:39
|
| if one coursenumber will only ever have one testkey and the formula to generate that testkey is NEVER expected to change, then you can have a table with columns, coursenumber & coursedate, plus a calculated column (testkey?) as the formula above using coursedate not getdate. does that answer your question? |
 |
|
|
Manoool
Starting Member
6 Posts |
Posted - 2007-11-12 : 13:55:21
|
| Nothe test key which is the a2 will be change with each entrybecause coursenumber is an identityI will explain the issue with more detailsI want to create primary key from 6 integer digits that contain two partthe first part is the first two number from the yearthe second part is auto generation number from 0000 to 9999for example: in this year "2007"the number will be from 070000 to 079999and I do not know how I can do this????????and some person give me this procedure that I mention beforeto solve this but I did not how to use it!!!!!!!if have a better solution please help meI am waiting |
 |
|
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-12 : 14:50:57
|
| can courseNumber 99 have a testkey 070000 if courseNumber 55 has a testkey 070000? or should it testkey be unique for every courseNumber? |
 |
|
|
|
|
|
|
|