Substring With Zero Length?

Sep 19, 2007

I'm using a substring expression in a Derived Column transformation to create a new column (string data) out of a segment of another. The length of the new column data is calculated at run time based on the contents of other columns, and under some circumstances may be zero.

Is this kocher, or will it lead to 'unpredictable' results? Coz unexpected results is what I'm getting, not in the row concerned, but in the rows following......

View 1 Replies


ADVERTISEMENT

What Is The Max Length Of Substring Function.

Mar 16, 2001

hi thanks for your help

update vendor_invoice
set de_ftpdownload= (select SUBSTRING(de_ftpdownload,1,CHARINDEX('.',de_ftpdow nload,0)-1)as de_ftpdownload from vendor_invoice)
where vendor_invoice_id =931

This get me this error.... so what is the max allowable length of substring function.

Server: Msg 536, Level 16, State 3, Line 1
Invalid length parameter passed to the substring function.
The statement has been terminated.
Thanks
Al

View 1 Replies View Related

Using Of Substring With Dynamic Values For Length Parameter

Feb 12, 2003

Hi everybody,

I want to use substring with dynamic
values for length parameter
but result is different compare to
static parameter.

declare
@x smallint,
@y smallint,
@string varchar(250)


set @x = 0
set @string = '17898880219800alex3.5'

select @y = charindex('',@string,@x)
-- result varchar(5)
select substring(@string,@x,5)

select @y
-- result varchar(250) !!!!!!

select substring(@string,@x,@y)

Any Idea why ?

View 3 Replies View Related

Invalid Length Parameter Passed To The Substring F

Aug 13, 2007

Hi there when i tried to execute the following query in sql server

select au_fname,
SUBSTRING(P1.au_lname, CHARINDEX('/', P1.au_lname) + 1,
CHARINDEX('=', P1.au_lname, 1)-3)AS [Full Name]
from authors as P1

i will get the error like
"Invalid length parameter passed to the substring function."

If i remove -3 from there it works fine...
Please can anyone clarify this issue.

Thank You.

pavan

View 3 Replies View Related

Invalied Length Parameter Passed The Substring Function

Nov 12, 2004

Does anyone know what the above error message means?

View 4 Replies View Related

Invalid Length Parameter Passed To Substring Function

Mar 3, 2014

I have a sql job which will execute the below stored proc.

Basically it Refresh the data by truncating the tables and using BCP to import the data. Job was running fine but today got a error message.

Invalid length parameter passed to the substring function. [SQLSTATE 42000] (Error 536). The step failed.

USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[Refresh_tables]

[Code] ......

View 2 Replies View Related

Invalid Length Parameter Passed To The SUBSTRING Function.

Feb 1, 2008

Hi,

I was trying to execute the following query.

select substring(ISNULL(CAST(FullAdress AS NVARCHAR(MAX)),''),1,charindex(',',ISNULL(CAST(FullAdress AS NVARCHAR(MAX)),''))-1) from tbl_lrf_company_details_with_codes


but i am getting the error as "Invalid length parameter passed to the SUBSTRING function."
Please advice
Thanks In advance

View 4 Replies View Related

Invalid Length Parameter Passed To The SUBSTRING Function

May 27, 2008



SELECT

C.Description,

SUBSTRING (

(CONVERT (VARCHAR (255), D.CurrentXmlValue)), --expression

(CHARINDEX ('>', CONVERT (VARCHAR (255), D.CurrentXmlValue)) + 1), --start

( (LEN (CONVERT (VARCHAR (255), D.CurrentXmlValue))) -

(CHARINDEX ('>', CONVERT (VARCHAR (255), D.CurrentXmlValue))*2) - 1

)--length

) AS Version

FROM

:
:
WHERE
:
:
This does not work while

:
:

--SUBSTRING (

(CONVERT (VARCHAR (255), D.CurrentXmlValue)) as expression, --expression

(CHARINDEX ('>', CONVERT (VARCHAR (255), D.CurrentXmlValue)) + 1) as start, --start

( (LEN (CONVERT (VARCHAR (255), D.CurrentXmlValue))) -

(CHARINDEX ('>', CONVERT (VARCHAR (255), D.CurrentXmlValue))*2) - 1

) as length --length

--) AS Version

:
:

works!!
I get

Msg 536, Level 16, State 5, Line 2

Invalid length parameter passed to the SUBSTRING function.
Error.
Any idea why i am getting this??
I am trying to get rid of xml tags in the column.

Thanks,

View 4 Replies View Related

Transact SQL :: Invalid Length Parameter Passed To Left Or Substring

Dec 1, 2015

is it possible to identify which value is causing me the above  error message and how to resolve it,These are for British postcodes.

create table #tmp (postcode varchar(200) NULL)
insert into #tmp values ('NULL')
insert into #tmp values ('-')
insert into #tmp values ('.')
insert into #tmp values ('0L6 7TP')
insert into #tmp values ('AB10 1WP')
insert into #tmp values ('AB51 5HH')

[code]...

This is the main query

select postcode,LEFT([Postcode], CHARINDEX(' ',[Postcode]) - 1)
from #tmp
order by Postcode
drop table #tmp

View 4 Replies View Related

Error: Invalid Length Parameter Passed To The SUBSTRING Function.

Sep 28, 2007

Hi,

I am using a simple procedure to pivot results (found in another forum and adapted it). It is done on SQL Server 2005 server with all service packs. Procedure:
**************
ALTER Procedure [dbo].[EthnicityPivot] @StDate as Datetime, @EndDate as Datetime
as
begin
DECLARE @Teams varchar(2000)

truncate table ForEthnicPivot

INSERT INTO ForEthnicPivot
SELECT DISTINCT COUNT(ID), Team, Ethnicity
FROM dbo._EthnicityByTeamEpisode
where Startdate between @StDate and @EndDate
GROUP BY Ethnicity, Team

SET @Teams = ''
--// Get a list of the pivot columns that are important to you.

SELECT @Teams = @Teams + '[' + Team + '],'
FROM (SELECT Distinct Team FROM ForEthnicPivot) Team
--// Remove the trailing comma

SET @Teams = LEFT(@Teams, LEN(@Teams)-1)
--// Now execute the Select with the PIVOT and dynamically add the list
--// of dates for the columns
EXEC( 'SELECT * FROM ForEthnicPivot PIVOT (SUM(countID) FOR Team IN (' + @Teams + ')) AS X' )
end
************

I can call the function:
exec EthnicityPivot '01/01/2007','09/09/2007'

and it works fine in SQL analyzer, but when I want to use it in Visual Studio in a new report I am getting this error
message:

There is an error in the query. Invalid length parameter passed to the SUBSTRING function. Incorrect syntax near ')'.

Anyone had similar error and sorted it?

Cheers

Polda

View 4 Replies View Related

Sql 2005 ... Invalid Length Parameter Passed To The SUBSTRING Function.

Oct 9, 2006

Hi,
I am new at sql 2000 and 2005, I have created a package in 2005 which I am trying to execute on a daily bases by creating a job. At first because of security issues the job would not execute. Hence, I had to create a credential and a proxy to run the job with sa account. Now it is giving me this error,
€œSQLServer Error: 536, Invalid length parameter passed to the SUBSTRING function. €œ
Through research I have no clue as what I need to do, or where to look.
The package runs without error when I execute the package itself.
Any help is greatly appreciated.
Thanks,
Lori

View 1 Replies View Related

Error In Query; Invalid Length Parameter Passed To The Substring Function

Nov 28, 2005

Hi
i got errro mess "Invalid length parameter passed to the substring function" from this below. Anyone how can give me a hint what cause this, and how i can solve it? if i remove whats whitin thoose [] it works, i dont use [] in the code :)
colums:
VLF_InfectionDestination is nvarchar 254

SELECT TOP 10 tb_AVVirusLog.VLF_VirusName, COUNT(tb_AVVirusLog.VLF_VirusName) AS number
FROM tb_AVVirusLog INNER JOIN
__CustomerMachines002 ON tb_AVVirusLog.CLF_ComputerName = __CustomerMachines002.FalseName
WHERE (CONVERT(varchar, tb_AVVirusLog.CLF_LogGenerationTime, 120) BETWEEN @fyear + @fmonth + @fday AND @tyear + @tmonth + @tday) AND
(__CustomerMachines002.folder_id = @folderId) [OR
(CONVERT(varchar, tb_AVVirusLog.CLF_LogGenerationTime, 120) BETWEEN @fyear + @fmonth + @fday AND @tyear + @tmonth + @tday) AND
(tb_AVVirusLog.VLF_InfectionDestination LIKE N'%@%')]
GROUP BY tb_AVVirusLog.VLF_VirusName
HAVING (NOT (tb_AVVirusLog.VLF_VirusName LIKE N'cookie'))
ORDER BY COUNT(tb_AVVirusLog.VLF_VirusName) DESC

View 7 Replies View Related

Odd Error Upon SqlDataReader.Read() Invalid Length Parameter Passed To The Substring Function.

Nov 12, 2003

An application I developed normally works great, but it seems that when processing a certian record (and none of the others so far), SQL Server throws this error:
"Invalid length parameter passed to the substring function."

Here's the code in question:

orderConnection.Open()
orderReader = orderCommand.ExecuteReader()
setControls(orderReader)

...

Private Sub setControls(ByVal dr As SqlDataReader)
If (dr.Read()) Then '<--*******problem line*******

The SqlDataReader (orderReader) doesn't blow up or anything until I call .Read() (and, as mentioned, this problem only occurs for one order). What could be happening here?

View 3 Replies View Related

T-SQL (SS2K8) :: Procedure Parameter Length Declaration Less Than Column Length?

Jun 30, 2014

is there any way or a tool to identify if in procedure the Parameter length was declarated less than table Column length ..

I have a table

CREATE TABLE TEST001 (KeyName Varchar(100) ) a procedure
CREATE PROCEDURE SpFindNames ( @KeyName VARCHAR(40) )
AS
BEGIN
SELECT KeyName FROM TEST001
WHERE KeyName = @KeyName
END
KeyName = @KeyName

Here table Column with 100 char length "KeyName" was compared with SP parameter "@KeyName" with length 40 char ..

IS there any way to find out all such usage on the ALL Procedures in the Database ?

View 2 Replies View Related

BlobColumn.GetBlobData() With Data Length &&> Integer Length (32767)

Mar 27, 2008

For those of you who would like to reference my exact issue, I'm dealing with the RSExecution SSIS package at the "Update Parameters" data flow task, at the Script Component.

The script tries to split parameter data into name and value. Unfortunately, I have several reports that are passing parameters that are very large. One example has over 65,000 characters all in the normal "&paramname=value&parm2=value..." format.

The code in the script works fine until it gets to one of these very large parameter sets. I have figured out what is causing the issue. Here's some code:

Dim paramBlob as Byte()
paramBlob = Row.BlobColumn.GetBlobData(0, Row.BlobColumn.Length)

The second parameter of the .GetBlobData function takes an INTEGER as its count! Therefore, no matter what kind of datatype I pass to the string that the script will later split, it will be limited to 32767 characters.

THIS IS A PROBLEM!!!

Does anyone know a workaround for this issue? I need all of the parameter data to be reported, and I would hate to have to skip over rows like this. Also, if I'm missing something, please fill me in!

Thanks for your help in advance,
LOSTlover

View 6 Replies View Related

CommandParameters.length Don't Match Parametervalues.length

Feb 24, 2008

I am trying to narrow down this problem.  Basically, I added 3 columns to my article table.  It holds the article id, article text, author and so on.  I tested my program before adding the additional field to the program.  The program works fine and I can add an article, and edit the same article even though it skips over the 3 new fields in the database.  It just puts nulls into those columns.So, now I have added one of the column names I added in the database to the code. I changed my businesslogic article.vb code and the addarticle.aspx, as well as the New article area in the addartivle.aspx.vb  page. The form now has an additional textbox field for the ShortDesc which is a short description of the article. This is the problem now:  The command parameters.length is 9 and there are 10 parameter values.  Right in the middle of the 10 values is the #4 value which I inserted into the code.  It says Nothing when I hover my mouse over the code after my program throws the exception in 17 below.  Why is  command parameters.length set to 9 instead of 10?  Why isn't it reading the information for value 4 like all the other values and placing it's value there and calculating 10 instead of 9? Where are these set in the program?  Sounds to me like they are hard coded in someplace and I need to change them to match everything else.  1 ' This method assigns an array of values to an array of SqlParameters.2 ' Parameters:3 ' -commandParameters - array of SqlParameters to be assigned values4 ' -array of objects holding the values to be assigned5 Private Overloads Shared Sub AssignParameterValues(ByVal commandParameters() As SqlParameter, ByVal parameterValues() As Object)6 7 Dim i As Integer8 Dim j As Integer9 10 If (commandParameters Is Nothing) AndAlso (parameterValues Is Nothing) Then11 ' Do nothing if we get no data12 Return13 End If14 15 ' We must have the same number of values as we pave parameters to put them in16 If commandParameters.Length <> parameterValues.Length Then17 Throw New ArgumentException("Parameter count does not match Parameter Value count.") 18 End If19 20 ' Value array21 j = commandParameters.Length - 122 For i = 0 To j23 ' If the current array value derives from IDbDataParameter, then assign its Value property24 If TypeOf parameterValues(i) Is IDbDataParameter Then25 Dim paramInstance As IDbDataParameter = CType(parameterValues(i), IDbDataParameter)26 If (paramInstance.Value Is Nothing) Then27 commandParameters(i).Value = DBNull.Value28 Else29 commandParameters(i).Value = paramInstance.Value30 End If31 ElseIf (parameterValues(i) Is Nothing) Then32 commandParameters(i).Value = DBNull.Value33 Else34 commandParameters(i).Value = parameterValues(i)35 End If36 Next37 End Sub ' AssignParameterValues38 39 40 41  

View 2 Replies View Related

Substring

Jul 5, 2001

Hi all,
I have just started using SQL7 and quite dumb at it.
Here is my problem

i have tables ip_address and ip_subnets. both contains more than 20,000 records. Though ideally each subnet should correspond to only one ip address it is not so due to SMS inventory and remote clients configurations etc.

As an example If my ip address is 141.151.128.78 I need to select only 141.151.128.64 ( or atleast 141.151.128.*)as the valid subnet. In other words I need to compare upto 3rd octet and only if it matches with ip address then declare that as the valid subnet.
Pls note that ip addresses vary for each machine though there will 4 octets, I can't use character positions as the nos in each octet might vary from 1-255.

Any help would be greatly appreciated
Pasted here under is the query script I am playing around with charcter poistions which are not working in my favor. Just added to explain my problems in more clearer way
select distinct system_data.name0, System_IP_Address_ARR.ip_addresses0, System_IP_subnets_Arr.ip_subnets0, system_disc.client0 from system_Data, System_IP_Address_ARR, system_ip_subnets_arr, system_disc where system_data.machineid = System_IP_Address_ARR.itemkey and system_data.machineid = system_ip_subnets_arr.itemkey and system_data.machineid = system_disc.itemkey and system_disc.client0 = 1 and substring(System_IP_Address_ARR.ip_addresses0,1,10 ) = substring(System_IP_subnets_ARR.ip_subnets0,1,10) and substring(System_IP_Address_ARR.ip_addresses0,10,1 ) = '.' and System_IP_subnets_ARR.ip_subnets0 not in ('11%.%.%.%','12%.%.%.%', '10%.%.%.%' , '10.%.%.%' , '1.%.%.%') order by System_DATA.name0


Arun

View 2 Replies View Related

Need Help On Substring

Nov 5, 2001

Hey you sql programming guru's

I need help seperating a name from first name and last name

The field is like this,

last name, first name
example Doe, John
I need to seperate the last name from the , to the first character
and the last name from the , to the last character.

I think I have to use a substring but not sure how tell it to stop and
start when it gets to the comma.

Can someone please help me.

Thanks,
Dianne

View 1 Replies View Related

SubString

Aug 8, 2001

Need to do something like SUBSSTRING in Access, any ideas?

View 1 Replies View Related

Using Substring

Oct 4, 2004

Hi

Can anyone show me how to do the following:

I have this snippet of data

ids
-----------------------------------
1582270|1582277
1582270|1582277|1582286
1582270

I want to return the id (the id may not always have the same number of numbers) after the last pipe (|) delimter.

So i want a rs like this :
ids
-----------------------------------
1582277
1582286
1582270


Thanks in advance

View 9 Replies View Related

Substring Help

Feb 4, 2005

Hi,
please help me in developing query to satisfy this...
i have table called test and the table data looks like this.

col1
123.abc
1.ab
12.cba

the query needs to return all rows data after . the result set should return this

abc
ab
cba

appreciate your help..
thanks
sskris

View 1 Replies View Related

Substring

Feb 3, 2004

I have a field that contaings 15 characters. I want to just pull the first 6. So anything that matches these 6 will be returned.

View 10 Replies View Related

Substring???

Apr 8, 2004

We have entries like below in a table. I need a query by which I can get the CustomerName from the below entries.


ACustomerName
ACustomerNameCredit
ACustomerNameDebit

Thanks!

View 14 Replies View Related

Substring

Jun 2, 2004

I an trying gto devide this one field that contains city state and zip into 3 seperate columns. The Column right now looks like this:

Coulumn1
-------------------------------
SOUTH EL MONTE CA91733617
BOSSIER LA71172
GARDENA CA90249107
MILWAUKEE WI53216
PARIS IL61944
DUQUOIN IL62832
REDWOOD FALLS MN56283
AUBURN ME04210


I tryed this:

use cimpro1
select substring(cust_shipto_addr_l3, 1, 19) as 'City',
substring(cust_shipto_addr_l3, 20, 21) as 'State',
substring (cust_shipto_addr_l3, 22, 31) as 'Zip'
from opcshto


For some reason, when I run the query I get this for State:

State
-------------------------
CA91733617
LA71172
CA90249107
WI53216
IL61944
IL62832
MN56283
ME04210


When I use the substring to only pull characters 20 and 21 it pulls everything startign at 20. I just want it to select character position 20 ans 21 for the state. As far as the substring for City and Zip, everything comes out fine. Its just State that I am having trouble with.

Any help is appreciated.

View 7 Replies View Related

Substring

Sep 13, 2006

iam trying to write a string function which will give me the id part of a mail id
but iam geting the string along with @ and when iam trying to remove the last char (@) iam getting error

query:
select substring(leadassignedtombemail,1,(CHARINDEX('@', leadassignedtombemail)))
from lead_details -----> Gives me id along with @


select substring(leadassignedtombemail,1,(CHARINDEX('@', leadassignedtombemail) - 1))
from lead_details ------------>gives me error "Invalid length parameter passed to the substring function."

But
select (CHARINDEX('@', leadassignedtombemail) - 1) from lead_details
works and gives me the length of id without counting @

where did i go wrong

View 2 Replies View Related

Help With Substring

Dec 1, 2006

i am trying to get the last name of the customer, but my db has the names stored as (first,middle, last) order in a single field. i am using the statment:
,RIGHT(ActCustName,LEN(ActCustName) - CHARINDEX(' ',ActCustName) ) AS LAST

but it only works if the customer does not have a middle name, otherwise it returs the middle+last as the last name. what should i do/ any ideas??? here is my code

select ActPrjMgr
,ActEmpId
,ActEmpName
,ActCustName
,RIGHT(ActCustName,LEN(ActCustName) - CHARINDEX(' ',ActCustName) ) AS LAST
,ActPrjCode
,left(ActPrjType,2) as Status
,ActEmpTaskCode
,left(ActBillingPeriod,11)as ppedate
,left(ActivityDate,11) as actdate
,ActTimevalue
from dbo.ACTIVITIES
where ActBudCat = 'labor'
and ActBillingPeriod = '11/17/2006'
and actprjcode <> ' '
and actprjcode is not null
--and ActBillingPeriod = @StartDate
order by ActPrjMgr
,ActEmpID
,ActEmpTaskCode
,ActivityDate

View 7 Replies View Related

Substring

Mar 19, 2007

Hi All

Iam new to sql, Iam using sql 2000 and have a field datatype varchar.

An example of the string: -

CN=Leighton Morgan/OU=WR/O=Extranet

I need to write a query that will allow me to extract the following:-

Name: Leighton Morgan
Company: WR
and lastly the word Extranet

Please can you help

Many Thanks

View 9 Replies View Related

Substring

Mar 19, 2007

Hi All

Iam new to sql, Iam using sql 2000 and have a field datatype varchar.

An example of the string: -

CN=Leighton Morgan/OU=WR/O=Extranet

I need to write a query that will allow me to extract the following:-

Name: Leighton Morgan
Company: WR
and lastly the word Extranet

Please can you help

Many Thanks

View 1 Replies View Related

Substring

Mar 19, 2007

Hi All

Iam new to sql, Iam using sql 2000 and have a field datatype varchar.

An example of the string: -

CN=Leighton Morgan/OU=WR/O=Extranet

I need to write a query that will allow me to extract the following:-

Name: Leighton Morgan
Company: WR
and lastly the word Extranet

Please can you help

Many Thanks

View 1 Replies View Related

Substring

Jan 25, 2006

i have a column that has "Full name" of an individual.

I want to create a new column with just the first name.

How do i populate this column with just the first name...ie it just takes the string until the space from the "full name" column.

View 5 Replies View Related

Substring

Oct 22, 2007

can anyone help me with the following report.

Create procedure Rpt_StaffDevelopmentReport
(@cmb1 as varchar(100),
@cmb2 as varchar(100) with encryption as

Begin
--@cmb1 is the site name (s.sitename), @cmb2 is the staffname in the form €˜surname,forename€™

--@cmb2 will need to be split based on the €˜,€™ within the string
--tables needed are staffDevelopment , staffMember and Site
end


Three Tables.

Site
Columns
Siteid, sitename, address1, address2

Staffmember
Staffed, surname, forename,sex, address1, address2, siteid

Staffdevelopment
Staffed, development, personal

View 7 Replies View Related

Substring Problem

Feb 1, 2007

Hi
 
In  my status table I m having field like
Actionby (COLUMN NAME)
-------------------
TravelDept
TravelDept
Approver
FinanceDept
TravelDept(xyz@yahoo.com)
 
I m having mail id along with TravelDept in some rows.
I want to retreive rows containing TravelDept.When i am retreving i wnat to retreive value 'TravelDept' which is having mail id also.
i have written one query,but its retreving only the value which is having mail id.
i want to retreive TravelDept value with mail id and Only TravelDept values also.
my query is:
select replace(SUBSTRING(S.Actionby,CHARINDEX('',S.Actionby,1) , CHARINDEX('(',S.Actionby,1)+0 ),')', '')  from status S;
But this query retreiving only 1 row only insteadof 3 rows.
Total 3  rows having TravelDept value.I want to retreive all these 3 rows.
please help me.
 
Thanks.
 
 

View 2 Replies View Related

Substring Sql Statement

Aug 31, 2007

I have a SQL column that contains something like this:






ORLANDO        ,FL.    32803

COCOA       , FL. 32922-8617

SATELLITE BCH,FL  32937-3523

TAMPA       , FL. 33609-3105

EAU GALLIE      ,FL.   32935
I need only the name of the city, dont need FL or the zip code, how can I do a substring statement on sql to get only that?
Thanks,
Erick

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved