Questions tagged [datalength]

DATALENGTH is a T-SQL function in SQL Server 2005+ which takes any column or variable, and returns the length of the data in bytes.

DATALENGTH is a T-SQL function in SQL Server 2005+ which takes any column or variable, and returns the length of the data in bytes.

Usually returns an int, but can return a bigint if used with varchar(max), nvarchar(max) or varbinary(max) datatypes.

It is comparable to the LEN function, but LEN trims the input, whereas DATALENGTH does not.

41 questions
0
votes
0 answers

Obtaining size of rows using DataLength and hard-coded column names fails

I am trying to write a SQL query that will show me the records that are largest in size along with the User Names associated with the record. SELECT Data.Id, User.UserName, ( ISNULL(DATALENGTH(ColumnA), 1) + …
webworm
  • 10,587
  • 33
  • 120
  • 217
0
votes
1 answer

database(ETL) testing using sql server

for ETL TESTING: when transforming from source table to destination or war house, if a column EMPLOYEENAME is null, replace it with "" and truncate to 50 characters in sql server 2014 i got a query to replace null with "". but i have to truncate…
shafna
  • 1
0
votes
1 answer

PHP PDO Data_length always returns "0"

Well, I'm just trying the following for around two hours now and I can't get it to work. The following code will always return "0". Please, can anyone see where is the problem. This should work as a charm. And in PhpMyAdmin, when I run the statement…
Logixor
  • 69
  • 1
  • 12
0
votes
1 answer

Unused length/value of the cell

I have a table column named user_id. where it auto increments whenever a new user registers. I think setting length/values of column at its maximum length (4294967295) can prevent explosive users registering that will use up the length/values. I'm…
0
votes
2 answers

Find records with Minimum length data

I have a table #tempTest with data like this: ID Name 1 A 2 AB 3 ABC 4 ABCD 5 ABCDE 6 ABCDEF 7 X 8 QRWXYZ Now I need the shortest name from the table. I've tried this way: SELECT TOP 1(name) Smallest FROM #tempTest GROUP BY…
Metaphor
  • 374
  • 1
  • 5
  • 20
0
votes
0 answers

Arguments imply differing number of rows

I used cases function under package memisc to combine several values under 1 column. For example, library(memisc) age=cases( "10-20"=(data$your_age=="10-15"|data$your_age=="16-20"), "21-30"=(data$your_age=="21-25"|data$your_age=="26-30") …
0
votes
0 answers

SQL Server: Trouble with empty varchar fields with different data lengths

Sorry, I couldn't succinctly put this into the title... I have fields in SQL Server 2008 tables for a website that are set to varchar not null default '' [empty string]. Naturally none of them have null values in but there are plenty of empty ones…
derren
  • 1
0
votes
1 answer

Handling file size for SQL FILESTREAM data

What is the proper way to handle file sizes when using Sql Server's FILESTREAM feature to store documents in the database? I know that you can use the TSQL command DATALENGTH() on the filestream column, but regarding to this Microsoft article this…
magnattic
  • 12,638
  • 13
  • 62
  • 115
0
votes
4 answers

Extended TYPE_NAME function that includes datalength

I'm thinking of creating a function of the format FULL_TYPE_NAME(type_id, max_length) that returns both the datatype and length in string format eg.: FULL_TYPE_NAME (231,-1) would return: nvarchar(max) Before I do this I wanted to check if tsql…
Jude Wood
  • 76
  • 6
0
votes
2 answers

SQL Server IMAGE data type conversion woes

We're converting a legacy, SQL Server 2000 database to SQL Server 2008. Both store binary files (JPG, BMP, DOC, and PDF) in an IMAGE column (I know the datatype has been deprecated, but changing this is not an option). The data is inserted the new…
paparush
  • 1,340
  • 1
  • 17
  • 25
-1
votes
2 answers

SQL Server DataLength issues

I have a column with the following data: SMITH SMITH SMITH SMITH SMITH. When doing a SELECT DATALENGTH from the table, I am getting a value of 72. However when I copy the column data and pop it in the select statement like the below, I get a length…
John
  • 263
  • 1
  • 15
1 2
3