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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-09-24 : 09:09:40
|
| supriya writes "I am trying to convert an integer variable to char and then concatenate it with another string. Somehow this is not working.the code is as followsCREATE TRIGGER [InsertPrimary] ON [Categories] FOR INSERT ASDECLARE @Primaryvalue int,@Prefix char(2),@PrimaryInsert char(3),@strPrimaryValue char(2)Select @PrimaryValue=Value, @Prefix=Prefix From KeyValues where TableName='Categories' and KeyName='CategoryID' If @PrimaryValue=0 SET @PrimaryValue=1Else SET @PrimaryValue=@PrimaryValue+1If @Prefix Is Null Begin SET @PrimaryInsert=@PrimaryValue EndElse Begin SET @strPrimaryValue=STR(@PrimaryValue) ***SET @PrimaryInsert=RTRIM(@Prefix) + RTRIM(@strPrimaryValue) EndUpdate Categories Set CategoryID=@PrimaryInsert where CategoryID='dum'Update KeyValues Set Value=@PrimaryValue Where TableName='Categories' and KeyName='CategoryID'the *** assignment is not working. I am expecting a string 'C0' but I only get 'C' not the zero. Whats wrong?" |
|
|
|
|
|