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 |
|
CSDevMan
Starting Member
5 Posts |
Posted - 2007-12-31 : 13:56:37
|
Hello everyone,Here I am fresh out of school and working on my first demo project to show potential employers and I am running into a snag with the database. So I am turning to you experts for some help, Thanks by the way as I have learned a lot by reading the articles and posts on this site! Here is the relevant background:I am building an ASP.Net in C# web app. with a SQL DB (I am working with SQL Server 2005 Management Studio Express) the App. will be an online printing ordering system which I am basing off a system we use in my current job. I would actually like to get this all completed and leave as a gift (the current system is outdated) for my current employer before I head off to my new career!!Here is the layout of my test Orders table:[ID_Num] [int] IDENTITY(1,1) NOT NULL,[Date] [smalldatetime] NOT NULL,[Quantity] [int] NOT NULL,[Ord_Num] [char](15) -- to be created via triggerI have the Identity column (Thanks to this site!) and everything working except the Ord_Num column this is where I am struggling. I want to create a trigger to fire on the creation of a new record that will combine the ID_Num and the Date to create the actual Order_Num. So the finished order number will look like this “123107000001”.Thanks in advance for the help and Happy New Years to everyone!!Thanks, Kurt |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-12-31 : 14:01:09
|
| This is not a good design. You should not use a trigger just to combine columns. And this should just be handled at the presentation layer rather than at the database layer. If you must follow this design, then why not use a calculated column instead?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
CSDevMan
Starting Member
5 Posts |
Posted - 2007-12-31 : 16:33:42
|
Thanks Tara for the quick reply!One of the articles I read from here suggested using Identity (the presentation layer was also an option) and implementing with a Trigger, Computed Column or a View. Maybe I misunderstood the concept. Could you expand on why this is not a good design? I thought combining the identity and the date might be a cleaner implementation versus the presentation layer? I also need to return the Order Number back to the customer via e-mail after the order is submitted. This may be a stupid question but, is a calculated column the same as computed column?Also if you could provide some code examples that would be very much appreciated. Sorry we touched on just enough SQL in school to be dangerous!! Which is a shame because now I can tell it is vey important! Thanks again!!Thanks, Kurt |
 |
|
|
|
|
|
|
|