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 |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2009-06-03 : 10:57:10
|
Hi I hava table customer with the following fieldslike customer id ,lastname ,firstname,username.The table is populated from front -end and i have a stored procedure for this .But the username name field is the problem here. i have a function that calculates the username based on firstname and lastname and then i have to make the insert . select dbo.getusername(@firstname,@lastname)while the others can be inserted directly via paarmetersinsert into (customer id ,lastname ,firstname,username.)values((@customer id ,@lastname ,@firstname,username.)How can i achieve this in one sp.tahnks in advance. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-03 : 11:15:06
|
I would do:declare @username varchar(255)select @username = dbo.getusername(@firstname,@lastname)insert into ([customer id] ,lastname ,firstname,username)values(@customer_id ,@lastname ,@firstname,@username) No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2009-06-03 : 11:59:31
|
quote: Originally posted by webfred I would do:declare @username varchar(255)select @username = dbo.getusername(@firstname,@lastname)insert into ([customer id] ,lastname ,firstname,username)values(@customer_id ,@lastname ,@firstname,@username) No, you're never too old to Yak'n'Roll if you're too young to die.
thanks webfred. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-03 : 12:17:26
|
welcome No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2009-06-08 : 15:42:18
|
Why would you store what is essentially a "derived" field in the database? Ever heard of normalization?Terry-- Procrastinate now! |
|
|
|
|
|
|
|