ProgrammingB52
Technical User
I have a table Student with fields stdID,fName,lName,email and username. I have another table studentType with a field degType for degreeType. The username field is blank and I am trying to write in TSQL that the username field be the (degreeType initial + _ + fName + lName). For example for a graduate student named Sally Jones, username = g_sallyjones.
My problem is not with the string manipulation that works. My problem is I can't put the @username field (the field with the correct string such as g_sallyjones) into the username field of the Student table. Below is my code.Please help. I have actually been struggling for 2 days on this.
drop procedure prSetUsername
go
create procedure prSetUsername
@username varchar(25)=NULL
as
select @username = (substring(degType,1,1) + '_ ' + fName +lName)
from student,StudentType
where student.stdID=StudentType.stdID
insert into student (username) Values (@username)
GO
execute prsetUsername
GO
select * from student
My problem is not with the string manipulation that works. My problem is I can't put the @username field (the field with the correct string such as g_sallyjones) into the username field of the Student table. Below is my code.Please help. I have actually been struggling for 2 days on this.
drop procedure prSetUsername
go
create procedure prSetUsername
@username varchar(25)=NULL
as
select @username = (substring(degType,1,1) + '_ ' + fName +lName)
from student,StudentType
where student.stdID=StudentType.stdID
insert into student (username) Values (@username)
GO
execute prsetUsername
GO
select * from student