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
1
vote
2 answers

Does the 'Datalength' command from T-sql have a c# Lambda equivalent?

In T-SQL, I can write: select datalength(somecolumn_that_is_defined_as_text) from somedatabase and it returns the length, in bytes, of that column. Can this be done in using a Lambda expression?
Erik Lane
  • 11
  • 1
1
vote
3 answers

SQL Server - Truncate Using DATALENGTH

Is there a way to truncate an nvarchar using DATALENGTH? I am trying to create an index on a column, but an index only accepts a maximum of 900 bytes. I have rows that consist of 1000+ bytes. I would like to truncate these rows and only accept the…
janinaj
  • 154
  • 1
  • 3
  • 10
1
vote
1 answer

SQL Server : datalength conversion

I have a table dbo.files with 9 columns that include file_size and created_time and filepath. Sample values: file_size = 528300 created_time = 2012-06-28 09:31:17.610 I have the following query where I'm trying to show the total # of MB have been…
Docjay
  • 123
  • 3
  • 14
1
vote
1 answer

T-SQL surprising DATALENGTH values of char and nchar

SELECT DATALENGTH('źźźź') -- 4 SELECT DATALENGTH(CONVERT(char, 'źźźź')) -- 30 SELECT DATALENGTH(CONVERT(nchar, 'źźźź')) -- 60 SELECT DATALENGTH(CONVERT(varchar, 'źźźź')) -- 4 SELECT DATALENGTH(CONVERT(nvarchar,…
Bartłomiej Sobieszek
  • 2,692
  • 2
  • 25
  • 40
1
vote
1 answer

Using entity framework, how do you select the datalength of a column plus other column data

If I have a SQL table X with columns A and B, and I want to select the DATALENGTH of B, as well as column A, how do I do this in a single expression? For example: var results = dc.X.Select(x => SqlFunctions.DataLength(x.B)) will return me results…
Dan
  • 1,215
  • 1
  • 10
  • 22
1
vote
1 answer

How to set data length in ALV?

I have "Müşteri siparişinden müşteri siparişine nakil kaydı" text from HTEXT. HTEXT is a 25-character field you know. But when I use "WRITE" command, it writes "Müşteri siparişinden müşteri siparişine nakil kaydı". I changed my code for ALV. Then it…
cethint
  • 2,231
  • 8
  • 28
  • 31
1
vote
3 answers

SQL: Take the last 4000 characters from text

I have a text column that I want to see if it has larger than 4000 characters. If it does have more than 4000 characters, then start at the right most character and go back 4000 characters. I realize that the following code is not correct. But it…
Jeremy F.
  • 1,778
  • 11
  • 51
  • 86
0
votes
0 answers

SQL error: The (maximum) expected data length is 510, while the returned data length is 1010

I have a data source from Cloudera Hive ODBC in MS SQL Server connected via a linked server. When I try to query one of the tables it throws an error as follows ' OLE DB provider 'MSDASQL' for linked server 'CL' returned data that does not match the…
Hema
  • 1
  • 2
0
votes
3 answers

Filter on a specific column in my table is not working

I am using SQL Server 2014 and I have this simple T-SQL query: USE MyDatabase SELECT * FROM [t1] WHERE DATALENGTH([Email]) > 0 OR [Email] <> ' ' I want to exclude all records where the Email field appears BLANK or NULL. When running the above…
user3115933
  • 4,303
  • 15
  • 54
  • 94
0
votes
1 answer

Created factors with EFA, tried regressing (lm) with control variables - Error message "variable lengths differ"

EFA first-timer here! I ran an Exploratory Factor Analysis (EFA) on a data set ("df1" = 1320 observations) with 50 variables by creating a subset with relevant variables only that have no missing values ("df2" = 301 observations). I was able to…
0
votes
2 answers

What is the data length of CLOB in oracle?

Could you please let me know what is the Data length for the 2nd column_id of "CLOB" data type in the Employee table? I see some blogs where it says maximum data length is : (4GB -1)* (database block size). I'm new to this data designing. Table :…
Anitha
  • 77
  • 1
  • 2
  • 9
0
votes
1 answer

What is the data length for those columns in Oracle - Table designing

Could you please let me know what is the Data length for those columns in the Employee table? No value is specified for "NUMBER and DATE datatypes too. I'm new to this data designing. Table : Employee Column_Name ----- Data_Type ------- Nullable…
Anitha
  • 77
  • 1
  • 2
  • 9
0
votes
1 answer

EndsWith SQL query for VARBINARY(MAX) FILESTREAM columns

Currently I have two SQL query proposals which call DATALENGTH on the same VARBINARY column more than once, due to conditions in the WHERE clause. Do these multiple calls to DATALENGTH in the same query interfere in the performance, or can the…
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
0
votes
0 answers

How to Convert Nvarchar(Max) to BLOB IN SQL SERVER?

How to convert Nvarchar(Max) to BLOB? A SQLServer view have been using in Oracle through Databaselink. One of the text column datatype is NVARCHAR(MAX) and when I checked the max Lenght of Text column is 52000 characters. If I use NVARCHAR(MAX)…
K.Tom
  • 175
  • 1
  • 6
  • 16
0
votes
1 answer

Using datalength(varbinary datatype) in substring

I am trying to select some varbinary data from TABLE(DATA varbinary(2048)) to my .NET dll without any padding. All my records are currently 64 bytes long but they may vary in the future. I use a stored procedure that does this: select…
Evan V.
  • 37
  • 1
  • 7