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 2008 Forums
 Transact-SQL (2008)
 How to Update length Automatically

Author  Topic 

Niladri20052006
Starting Member

4 Posts

Posted - 2012-12-04 : 07:13:53
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

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-12-04 : 07:26:18
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

--
Chandu
Go to Top of Page
   

- Advertisement -