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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query regarding storing field in Database

Author  Topic 

ambujnema
Starting Member

11 Posts

Posted - 2009-03-12 : 09:12:44
hi All

I have a problem while saving the field in database

IF (@IsReplacementFile='1')
BEGIN
SET @NewFileName=@FileName+'_'+ CAST(@AccountId AS VARCHAR)+ '_' + CAST(@TitleId AS VARCHAR) + '_' +CAST(@IdentityValue AS VARCHAR)+'_R'+@Extension
END
ELSE
BEGIN
SET @NewFileName=@FileName+'_'+ CAST(@AccountId AS VARCHAR)+ '_' + CAST(@TitleId AS VARCHAR) + '_' +CAST(@IdentityValue AS VARCHAR)+@Extension
END


In that I am storing the file name in "filename_AccountId_TitleId_identityfield_R.extension and

filename_AccountId_TitleId_identityfield_R.extension

my problem is that when titleID is comming as Null these things are not saving in the database in the proper format

insted it is saving as null ,

Please tell where i am wrong

guptam
Posting Yak Master

161 Posts

Posted - 2009-03-12 : 10:47:09
Well the statements above don't tell us much. How are each of those variables are being set? Paste rest of you code please.



--
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCITP: Database Administrator
MCTS: SQL Server 2005
http://sqllearnings.blogspot.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-12 : 13:20:53


IF (@IsReplacementFile='1')
BEGIN
SET @NewFileName=COALESCE(@FileName+'_','')+ COALESCE(CAST(@AccountId AS VARCHAR)+ '_','') + COALESCE(CAST(@TitleId AS VARCHAR) + '_','') +COALESCE(CAST(@IdentityValue AS VARCHAR)+'_R','')+COALESCE(@Extension,'')
END
ELSE
BEGIN
SET @NewFileName=COALESCE(@FileName+'_','')+ COALESCE(CAST(@AccountId AS VARCHAR)+ '_','') + COALESCE(CAST(@TitleId AS VARCHAR) + '_','') +COALESCE(CAST(@IdentityValue AS VARCHAR),'')+COALESCE(@Extension,'')
END

Go to Top of Page

ambujnema
Starting Member

11 Posts

Posted - 2009-03-12 : 23:00:11
Thanks for the reply

I got the answer
Go to Top of Page
   

- Advertisement -