SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to Update length Automatically
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

4 Posts

Posted - 12/04/2012 :  07:13:53  Show Profile  Reply with Quote
Hi All,

From a table I am getting the length of character in a column. My query is below

SELECT b.[file_id],b.[lineno],b.fileContent, datalength(b.fileContent) Length1
FROM FileBascContent b join filebasic on filebasic.[file_id]=b.[file_id]
WHERE substring(b.fileContent,1,4)
not in('VOL1','HDR1','UHL1','UTL1','HDR2','EOF1','EOF2') and filebasic.[file_id]=347

I am getting the result 98, 97 and 100 which is fine for me.

Is there any way which will add space 2 or 3 and the length will be 100. Which I want is that all the length which are not 100, should be hundred.

Is there any way to do that?

Please help!

Niladri Sekhar Biswas

Flowing Fount of Yak Knowledge

2240 Posts

Posted - 12/04/2012 :  07:26:18  Show Profile  Reply with Quote
If the data type of b.fileContent column is CHAR(100), then u can always get datalength(b.fileContent) = 100 and len(b.fileContent) is actual string length

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000