Cannot Compare NVarChar(Max) Fields Over 4000 Chars

Oct 24, 2006

I had a post a week or so ago with this issue, I found the cause, but cannot figure out how to fix it...
 The problem is the comparison on the NVarChar(Max) fields when one of them exceeds 4000 chars. If I comment out the following lines of the stored proc, everything works. I tested without using COALESCE and it still does not work. COALESCE(Comments, '') = COALESCE(@o_Comments, '') ANDCOALESCE(SpecialNotes, '') = COALESCE(@o_SpecialNotes, '') ANDCOALESCE(IAppComments, '') = COALESCE(@o_IAppComments, '') ANDCOALESCE(MgmtNotes, '') = COALESCE(@o_MgmtNotes, '') AND  set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[pe_updateAppraisal]
-- Add the parameters for the stored procedure here
@OrderId INT,
@FileNumber NVarChar(25),
@OrderDate DateTime,
@ClientID NVarChar(25),
@ClientFileNumber NVarChar(25),
@PropertyTypeID INT,
@EstimatedValue money,
@PurchaseValue money,
@LoanOfficer NVarChar(50),
@ReportID INT,
@ReportFee money,
@FeeBillInd bit,
@FeeCollectInd bit,
@CollectAmt money,
@Borrower NVarChar(50),
@StreetAddrA NVarChar(50),
@StreetAddrB NVarChar(50),
@City NVarChar(50),
@CountyID INT,
@StateID INT,
@Zip NVarChar(50),
@ContactName NVarChar(50),
@PhoneA NVarChar(50),
@PhoneB NVarChar(50),
@PhoneC NVarChar(50),
@ApptDate DateTime,
@ApptTime NVarChar(25),
@AppraiserID INT,
@InspectionDate DateTime,
@DateMailed DateTime,
@TrackingInfo NVarChar(50),
@ReviewedBy INT,
@PreNotesID INT,
@PostNotesID INT,
@StatusID INT,
@Comments NVarChar(MAX),
@SpecialNotes NVarChar(MAX),
@MgmtName NVarChar(50),
@MgmtContactName NVarChar(50),
@MgmtAddress NVarChar(50),
@MgmtPhone NVarChar(50),
@MgmtFax NVarChar(50),
@MgmtFee money,
@CheckNumber NVarChar(25),
@MgmtNotes NVarChar(MAX),
@SentAppraiser DateTime,
@InfoReceived DateTime,
@CheckReceived DateTime,
@CheckMailed DateTime,
@INumFamilies NVarChar(10),
@IStyle NVarChar(15),
@IUnit NVarChar(15),
@IConstruction NVarChar(15),
@IBasement NVarChar(10),
@IBFinished NVarChar(10),
@IGarage NVarChar(10),
@INumCars NVarChar(2),
@IGarageType NVarChar(10),
@IContactHas NVarChar(10),
@IAvailable NVarChar(10),
@IInformedAmt NVarChar(5),
@IRealtorContract NVarChar(10),
@IContractContact NVarChar(50),
@IPermitCO NVarChar(10),
@ICORenewal NVarChar(10),
@IRenewalInt NVarChar(15),
@IAppComments NVarChar(MAX),
@IKitchen1 NVarChar(5),
@IKitchen2 NVarChar(5),
@IKitchen3 NVarChar(5),
@IKitchen4 NVarChar(5),
@IKitchenB NVarChar(5),
@IBedroom1 NVarChar(5),
@IBedroom2 NVarChar(5),
@IBedroom3 NVarChar(5),
@IBedroom4 NVarChar(5),
@IBedroomB NVarChar(5),
@IBathroom1 NVarChar(5),
@IBathroom2 NVarChar(5),
@IBathroom3 NVarChar(5),
@IBathroom4 NVarChar(5),
@IBathroomB NVarChar(5),
@AppraiserPerc NVarChar(6),
@AppraiserFee money,

@o_OrderId INT,
@o_FileNumber NVarChar(25),
@o_OrderDate DateTime,
@o_ClientID NVarChar(25),
@o_ClientFileNumber NVarChar(25),
@o_PropertyTypeID INT,
@o_EstimatedValue money,
@o_PurchaseValue money,
@o_LoanOfficer NVarChar(50),
@o_ReportID INT,
@o_ReportFee money,
@o_FeeBillInd bit,
@o_FeeCollectInd bit,
@o_CollectAmt money,
@o_Borrower NVarChar(50),
@o_StreetAddrA NVarChar(50),
@o_StreetAddrB NVarChar(50),
@o_City NVarChar(50),
@o_CountyID INT,
@o_StateID INT,
@o_Zip NVarChar(50),
@o_ContactName NVarChar(50),
@o_PhoneA NVarChar(50),
@o_PhoneB NVarChar(50),
@o_PhoneC NVarChar(50),
@o_ApptDate DateTime,
@o_ApptTime NVarChar(25),
@o_AppraiserID INT,
@o_InspectionDate DateTime,
@o_DateMailed DateTime,
@o_TrackingInfo NVarChar(50),
@o_ReviewedBy INT,
@o_PreNotesID INT,
@o_PostNotesID INT,
@o_StatusID INT,
@o_Comments NVarChar(MAX),
@o_SpecialNotes NVarChar(MAX),
@o_MgmtName NVarChar(50),
@o_MgmtContactName NVarChar(50),
@o_MgmtAddress NVarChar(50),
@o_MgmtPhone NVarChar(50),
@o_MgmtFax NVarChar(50),
@o_MgmtFee money,
@o_CheckNumber NVarChar(25),
@o_MgmtNotes NVarChar(MAX),
@o_SentAppraiser DateTime,
@o_InfoReceived DateTime,
@o_CheckReceived DateTime,
@o_CheckMailed DateTime,
@o_INumFamilies NVarChar(10),
@o_IStyle NVarChar(15),
@o_IUnit NVarChar(15),
@o_IConstruction NVarChar(15),
@o_IBasement NVarChar(10),
@o_IBFinished NVarChar(10),
@o_IGarage NVarChar(10),
@o_INumCars NVarChar(2),
@o_IGarageType NVarChar(10),
@o_IContactHas NVarChar(10),
@o_IAvailable NVarChar(10),
@o_IInformedAmt NVarChar(5),
@o_IRealtorContract NVarChar(10),
@o_IContractContact NVarChar(50),
@o_IPermitCO NVarChar(10),
@o_ICORenewal NVarChar(10),
@o_IRenewalInt NVarChar(15),
@o_IAppComments NVarChar(MAX),
@o_IKitchen1 NVarChar(5),
@o_IKitchen2 NVarChar(5),
@o_IKitchen3 NVarChar(5),
@o_IKitchen4 NVarChar(5),
@o_IKitchenB NVarChar(5),
@o_IBedroom1 NVarChar(5),
@o_IBedroom2 NVarChar(5),
@o_IBedroom3 NVarChar(5),
@o_IBedroom4 NVarChar(5),
@o_IBedroomB NVarChar(5),
@o_IBathroom1 NVarChar(5),
@o_IBathroom2 NVarChar(5),
@o_IBathroom3 NVarChar(5),
@o_IBathroom4 NVarChar(5),
@o_IBathroomB NVarChar(5),
@o_AppraiserPerc NVarChar(6),
@o_AppraiserFee money
AS
BEGIN

UPDATE Orders
SET FileNumber = @FileNumber,
OrderDate = @OrderDate, ClientID = @ClientID,
ClientFileNumber = @ClientFileNumber, PropertyTypeID = @PropertyTypeID,
EstimatedValue = @EstimatedValue, PurchaseValue = @PurchaseValue,
LoanOfficer = @LoanOfficer, ReportFee = @ReportFee,
FeeBillInd = @FeeBillInd, FeeCollectInd = @FeeCollectInd,
CollectAmt = @CollectAmt, Borrower = @Borrower,
StreetAddrA = @StreetAddrA, StreetAddrB = @StreetAddrB,
City = @City, CountyID = @CountyID, StateID = @StateID, Zip = @Zip,
ContactName = @ContactName, PhoneA = @PhoneA, PhoneB = @PhoneB,
PhoneC = @PhoneC, ApptDate = @ApptDate, ReportID = @ReportID,
ApptTime = @ApptTime, AppraiserID = @AppraiserID,
InspectionDate = @InspectionDate, DateMailed = @DateMailed,
TrackingInfo = @TrackingInfo, ReviewedBy = @ReviewedBy,
StatusID = @StatusID, Comments = @Comments,
SpecialNotes = @SpecialNotes, CheckNumber = @CheckNumber,
MgmtName = @MgmtName, MgmtContactName = @MgmtContactName,
MgmtAddress = @MgmtAddress, MgmtPhone = @MgmtPhone,
MgmtFax = @MgmtFax, MgmtFee = @MgmtFee, MgmtNotes = @MgmtNotes,
CheckMailed = @CheckMailed, CheckReceived = @CheckReceived,
InfoReceived = @InfoReceived, SentAppraiser = @SentAppraiser,
PreNotesID = @PreNotesID, PostNotesID = @PostNotesID,
INumFamilies = @INumFamilies,
IStyle = @IStyle, IUnit = @IUnit, IConstruction = @IConstruction,
IBasement = @IBasement, IBFinished = @IBFinished,
IGarage = @IGarage, INumCars = @INumCars,
IGarageType = @IGarageType, IContactHas = @IContactHas,
IAvailable = @IAvailable, IInformedAmt = @IInformedAmt,
IRealtorContract = @IRealtorContract, IContractContact = @IContractContact,
IPermitCO = @IPermitCO, ICORenewal = @ICORenewal,
IRenewalInt = @IRenewalInt, IAppComments = @IAppComments,
IBedroomB = @IBedroomB, IBedroom1 = @IBedroom1, IBedroom2 = @IBedroom2,
IBedroom3 = @IBedroom3, IBedroom4 = @IBedroom4, IKitchenB = @IKitchenB,
IKitchen1 = @IKitchen1, IKitchen2 = @IKitchen2, IKitchen3 = @IKitchen3,
IKitchen4 = @IKitchen4, IBathroomB = @IBathroomB, IBathroom1 = @IBathroom1,
IBathroom2 = @IBathroom2, IBathroom3 = @IBathroom4, IBathroom4 = @IBathroom4,
AppraiserPerc = @AppraiserPerc, AppraiserFee = @AppraiserFee
WHERE OrderID = @o_OrderId AND
COALESCE(FileNumber, '') = COALESCE(@o_FileNumber, '') AND
COALESCE(OrderDate, 01/01/1900) = COALESCE(@o_OrderDate, 01/01/1900) AND
COALESCE(ClientID, 0) = COALESCE(@o_ClientID, 0) AND
COALESCE(ClientFileNumber, '') = COALESCE(@o_ClientFileNumber, '') AND
COALESCE(PropertyTypeID, 0) = COALESCE(@o_PropertyTypeID, 0) AND
COALESCE(EstimatedValue, 0) = COALESCE(@o_EstimatedValue, 0) AND
COALESCE(PurchaseValue, 0) = COALESCE(@o_PurchaseValue, 0) AND
COALESCE(LoanOfficer, '') = COALESCE(@o_LoanOfficer, '') AND
COALESCE(ReportID, 0) = COALESCE(@o_ReportID, 0) AND
COALESCE(ReportFee, 0) = COALESCE(@o_ReportFee, 0) AND
COALESCE(FeeBillInd, 0) = COALESCE(@o_FeeBillInd, 0) AND
COALESCE(FeeCollectInd, 0) = COALESCE(@o_FeeCollectInd, 0) AND
COALESCE(CollectAmt, 0) = COALESCE(@o_CollectAmt, 0) AND
COALESCE(Borrower, '') = COALESCE(@o_Borrower, '') AND
COALESCE(StreetAddrA, '') = COALESCE(@o_StreetAddrA, '') AND
COALESCE(StreetAddrB, '') = COALESCE(@o_StreetAddrB, '') AND
COALESCE(City, '') = COALESCE(@o_City, '') AND
COALESCE(CountyID, 0) = COALESCE(@o_CountyID, 0) AND
COALESCE(StateID, 0) = COALESCE(@o_StateID, 0) AND
COALESCE(Zip, '') = COALESCE(@o_Zip, '') AND
COALESCE(ContactName, '') = COALESCE(@o_ContactName, '') AND
COALESCE(PhoneA, '') = COALESCE(@o_PhoneA, '') AND
COALESCE(PhoneB, '') = COALESCE(@o_PhoneB, '') AND
COALESCE(PhoneC, '') = COALESCE(@o_PhoneC, '') AND
COALESCE(ApptDate, 01/01/1900) = COALESCE(@o_ApptDate, 01/01/1900) AND
COALESCE(ApptTime, '') = COALESCE(@o_ApptTime, '') AND
COALESCE(AppraiserID, 0) = COALESCE(@o_AppraiserID, 0) AND
COALESCE(InspectionDate, 01/01/1900) = COALESCE(@o_InspectionDate, 01/01/1900) AND
COALESCE(DateMailed, 01/01/1900) = COALESCE(@o_DateMailed, 01/01/1900) AND
COALESCE(TrackingInfo, '') = COALESCE(@o_TrackingInfo, '') AND
COALESCE(ReviewedBy, 0) = COALESCE(@o_ReviewedBy, 0) AND
COALESCE(PreNotesID , 0) = COALESCE(@o_PreNotesID, 0) AND
COALESCE(PostNotesID, 0) = COALESCE(@o_PostNotesID, 0) AND
COALESCE(StatusID, 0) = COALESCE(@o_StatusID, 0) AND
/*COALESCE(Comments, '') = COALESCE(@o_Comments, '') AND
COALESCE(SpecialNotes, '') = COALESCE(@o_SpecialNotes, '') AND*/
COALESCE(CheckNumber, '') = COALESCE(@o_CheckNumber, '') AND
COALESCE(MgmtName, '') = COALESCE(@o_MgmtName, '') AND
COALESCE(MgmtContactName, '') = COALESCE(@o_MgmtContactName, '') AND
COALESCE(MgmtAddress, '') = COALESCE(@o_MgmtAddress, '') AND
COALESCE(MgmtPhone, '') = COALESCE(@o_MgmtPhone, '') AND
COALESCE(MgmtFax, '') = COALESCE(@o_MgmtFax, '') AND
COALESCE(MgmtFee, '') = COALESCE(@o_MgmtFee, '') AND
/*COALESCE(MgmtNotes, '') = COALESCE(@o_MgmtNotes, '') AND*/
COALESCE(SentAppraiser, 01/01/1900) = COALESCE(@o_SentAppraiser, 01/01/1900) AND
COALESCE(InfoReceived, 01/01/1900) = COALESCE(@o_InfoReceived, 01/01/1900) AND
COALESCE(CheckReceived, 01/01/1900) = COALESCE(@o_CheckReceived, 01/01/1900) AND
COALESCE(CheckMailed, 01/01/1900) = COALESCE(@o_CheckMailed, 01/01/1900) AND
COALESCE(INumFamilies, '') = COALESCE(@o_INumFamilies, '') AND
COALESCE(IStyle, '') = COALESCE(@o_IStyle, '') AND
COALESCE(IUnit, '') = COALESCE(@o_IUnit, '') AND
COALESCE(IConstruction, '') = COALESCE(@o_IConstruction, '') AND
COALESCE(IBasement, '') = COALESCE(@o_IBasement, '') AND
COALESCE(IBFinished, '') = COALESCE(@o_IBFinished, '') AND
COALESCE(IGarage, '') = COALESCE(@o_IGarage, '') AND
COALESCE(INumCars, '') = COALESCE(@o_INumCars, '') AND
COALESCE(IGarageType, '') = COALESCE(@o_IGarageType, '') AND
COALESCE(IContactHas, '') = COALESCE(@o_IContactHas, '') AND
COALESCE(IAvailable, '') = COALESCE(@o_IAvailable, '') AND
COALESCE(IInformedAmt, '') = COALESCE(@o_IInformedAmt, '') AND
COALESCE(IRealtorContract, '') = COALESCE(@o_IRealtorContract, '') AND
COALESCE(IContractContact, '') = COALESCE(@o_IContractContact, '') AND
COALESCE(IPermitCO, '') = COALESCE(@o_IPermitCO, '') AND
COALESCE(ICORenewal, '') = COALESCE(@o_ICORenewal, '') AND
COALESCE(IRenewalInt, '') = COALESCE(@o_IRenewalInt, '') AND
/*COALESCE(IAppComments, '') = COALESCE(@o_IAppComments, '') AND*/
COALESCE(IKitchen1, '') = COALESCE(@o_IKitchen1, '') AND
COALESCE(IKitchen2, '') = COALESCE(@o_IKitchen2, '') AND
COALESCE(IKitchen3, '') = COALESCE(@o_IKitchen3, '') AND
COALESCE(IKitchen4, '') = COALESCE(@o_IKitchen4, '') AND
COALESCE(IKitchenB, '') = COALESCE(@o_IKitchenB, '') AND
COALESCE(IBedroom1, '') = COALESCE(@o_IBedroom1, '') AND
COALESCE(IBedroom2, '') = COALESCE(@o_IBedroom2, '') AND
COALESCE(IBedroom3, '') = COALESCE(@o_IBedroom3, '') AND
COALESCE(IBedroom4, '') = COALESCE(@o_IBedroom4, '') AND
COALESCE(IBedroomB, '') = COALESCE(@o_IBedroomB, '') AND
COALESCE(IBathroom1, '') = COALESCE(@o_IBathroom1, '') AND
COALESCE(IBathroom2, '') = COALESCE(@o_IBathroom2, '') AND
COALESCE(IBathroom3, '') = COALESCE(@o_IBathroom3, '') AND
COALESCE(IBathroom4, '') = COALESCE(@o_IBathroom4, '') AND
COALESCE(IBathroomB, '') = COALESCE(@o_IBathroomB, '') AND
COALESCE(AppraiserPerc, 0) = COALESCE(@o_AppraiserPerc, 0) AND
COALESCE(AppraiserFee, 0) = COALESCE(@o_AppraiserFee, 0)
END 

View 13 Replies


ADVERTISEMENT

The Parameterized Query '(@contactdate Nvarchar(4000),@dnbnumber Nvarchar(4000),@prospect' Expects The Parameter '@futureopportunity', Which Was Not Supplied.

Jan 10, 2008

HI, I am running the below method which returns this error: The parameterized query '(@contactdate nvarchar(4000),@dnbnumber nvarchar(4000),@prospect' expects the parameter '@futureopportunity', which was not supplied" Please help.Private Shared Sub InsertData(ByVal sourceTable As System.Data.DataTable, ByVal destConnection As SqlConnection)
' old method: Lots of INSERT statements Dim rowscopied As Integer = 0
' first, create the insert command that we will call over and over:
destConnection.Open()Using ins As New SqlCommand("INSERT INTO [tblAppointmentDisposition] ([contactdate], [dnbnumber], [prospectname], [businessofficer], [phonemeeting], [followupcalldate2], [phonemeetingappt], [followupcalldate3], [appointmentdate], [appointmentlocation], [appointmentkept], [applicationgenerated], [applicationgenerated2], [applicationgenerated3], [comments], [newaccount], [futureopportunity]) VALUES (@contactdate, @dnbnumber, @prospectname, @businessofficer, @phonemeeting, @followupcalldate2, @phonemeetingappt, @followupcalldate3, @appointmentdate, @appointmentlocation, @appointmentkept, @applicationgenerated, @applicationgenerated2, @applicationgenerated3, @comments, @newaccount, @futureopportunity)", destConnection)
ins.CommandType = CommandType.Textins.Parameters.Add("@contactdate", SqlDbType.NVarChar)
ins.Parameters.Add("@dnbnumber", SqlDbType.NVarChar)ins.Parameters.Add("@prospectname", SqlDbType.Text)
ins.Parameters.Add("@businessofficer", SqlDbType.NChar)ins.Parameters.Add("@phonemeeting", SqlDbType.NVarChar)
ins.Parameters.Add("@followupcalldate2", SqlDbType.NVarChar)ins.Parameters.Add("@phonemeetingappt", SqlDbType.NVarChar)
ins.Parameters.Add("@followupcalldate3", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentdate", SqlDbType.NVarChar)
ins.Parameters.Add("@appointmentlocation", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentkept", SqlDbType.NVarChar)
ins.Parameters.Add("@applicationgenerated", SqlDbType.NVarChar)ins.Parameters.Add("@applicationgenerated2", SqlDbType.NVarChar)
ins.Parameters.Add("@applicationgenerated3", SqlDbType.NVarChar)ins.Parameters.Add("@comments", SqlDbType.Text)
ins.Parameters.Add("@newaccount", SqlDbType.NVarChar)ins.Parameters.Add("@futureopportunity", SqlDbType.NVarChar)
' and now, do the work: For Each r As DataRow In sourceTable.RowsFor i As Integer = 0 To 15
ins.Parameters(i).Value = r(i)
Next
ins.ExecuteNonQuery()
'If System.Threading.Interlocked.Increment(rowscopied) Mod 10000 = 0 Then
'Console.WriteLine("-- copied {0} rows.", rowscopied)
'End If
Next
End Using
destConnection.Close()
End Sub

View 6 Replies View Related

How Do You Construct A Dynamic Stored Procedure With More Than 4000 Chars

Sep 12, 2007

My problem (excuse me for being a novice) is that whenever the query becomes complex
in the @whereclause (and it does) it cant exceed the character limit of a nvarchar. Now if someone could shed some ligfht on this for me I would be
incredibly grateful. I have tried doing the exec(@var1 + @var2) but this did not seem to work.


I have included the stored procedure below.

ALTER PROCEDURE [dbo].[SearchTenderMultiRegions]
(
@whereclause nVarChar(MAX), --4000 chars
@PageIndex int,
@PageSize int
) AS



SET NOCOUNT ON;DECLARE @sql nvarChar(MAX)

SET @sql= 'SELECT * FROM (SELECT DISTINCT TOP (' + CONVERT(nvarchar(10),(@PageIndex*@PageSize))
SET @sql= @sql + ') ROW_NUMBER() OVER (ORDER BY Tenders.ID DESC)AS Row,

Tenders.ID,Tenders.Title,Address.Suburb,Tenders.ClosingDateTime,Tenders.IsApproved,Tenders.TendersSourceID, Tenders.SourceDate,
UserTracking.CreateUserID,UserTracking.CreateDateTime FROM Tenders LEFT JOIN TenderContact ON Tenders.ID = TenderContact.TendersID
LEFT JOIN TenderCategory ON Tenders.ID = TenderCategory.TendersID
LEFT JOIN TenderRegion ON Tenders.ID = TenderRegion.TendersID
LEFT JOIN RegionStateCountry ON TenderRegion.RegionStateCountryID = RegionStateCountry.ID
LEFT JOIN Address ON Tenders.ID = Address.TendersID
LEFT JOIN UserTracking ON Tenders.ID = UserTracking.TendersID
WHERE '

SET @sql= @sql + @whereclause
SET @sql = @sql + ') as TenderSearchEntries
WHERE Row between ('

SET @sql= @sql + CONVERT(nvarchar(10), @PageIndex)
SET @sql= @sql + ' - 1) * '
SET @sql= @sql + CONVERT(nvarchar(10), @PageSize)
SET @sql= @sql + '+ 1 and '
SET @sql= @sql + CONVERT(nvarchar(10), @PageIndex)
SET @sql= @sql + ' * '
SET @sql= @sql + CONVERT(nvarchar(10), @PageSize)

EXEC(@sql)

View 5 Replies View Related

NVarChar 4000 Limit

Mar 3, 2008

I'm using a function which splits a comma delimitted list of numbers which I call from a stored procedure. The list is defined as a NVarChar which has a maximum length of 4000 characters. I often need to pass more than 4000 characters. If I do so, I receive the error message below. Is there any way around this limitation? Thanks.


Msg 257, Level 16, State 2, Procedure up_ExportQuickSearchresults, Line 0
Implicit conversion from data type text to nvarchar is not allowed. Use the CONVERT function to run this query.

CREATE FUNCTION dbo.Split
(
@ItemList NVARCHAR(4000),
@delimiter CHAR(1)
)
RETURNS @IDTable TABLE (IDDir NVARCHAR(4000))
AS

BEGIN
DECLARE @tempItemList NVARCHAR(4000)
SET @tempItemList = @ItemList

DECLARE @i INT
DECLARE @IDDir NVARCHAR(4000)

SET @tempItemList = REPLACE (@tempItemList, ' ', '')
SET @i = CHARINDEX(@delimiter, @tempItemList)

WHILE (LEN(@tempItemList) > 0)
BEGIN
IF @i = 0
SET @IDDir = @tempItemList
ELSE
SET @IDDir = LEFT(@tempItemList, @i - 1)
INSERT INTO @IDTable(IDDir) VALUES(@IDDir)
IF @i = 0
SET @tempItemList = ''
ELSE
SET @tempItemList = RIGHT(@tempItemList, LEN(@tempItemList) - @i)
SET @i = CHARINDEX(@delimiter, @tempItemList)
END
RETURN
END


CREATE PROCEDURE up_ExportSelectedDirectors
@p_selectedDirectors NVARCHAR(4000)
AS
BEGIN

SELECT * FROM v_SearchResultsDirectors
WHERE IDDir IN (SELECT IDDir FROM split(@p_selectedDirectors, ','))
END
GO

View 5 Replies View Related

Ntext Over 4000 Chars Causes 'Data In Row (n) Was Not Update... String Or Binary Data Would Be Truncated...'

Oct 18, 2006

When I enter over 4000 chars in any ntext field in my SQL Server 2005 database (directly in the database and through the application) I get an error saying that the data could not be updated because string or binary data would be truncated.Has anyone ever seen this? I cannot figure out what is causing it, ntext should be able to hold a lot more data that this...

View 7 Replies View Related

Keeping Trailing Spaces On Function Returning Nvarchar(4000)

Mar 21, 2008

I'm trying desparately to write a PadRight function in SQL Server 2005. I seem to be failing miserably because the trailing spaces disappear when the data is returned. First of all, why does SQL Server think I want my string trimmed? And second, how do I overcome this? Code below:




Code Snippet
CREATE FUNCTION [dbo].[PadRight]
(

@sourceString NVARCHAR(4000),
@length INT,
@padCharacter NCHAR(1) = ' ',
@trimBeforePadding BIT = 1
)
RETURNS NVARCHAR(4000) AS
BEGIN

DECLARE @returnStringLength AS INT, @toReturn AS NVARCHAR(4000)
SET @toReturn = LEFT(@sourceString, @length)


IF @trimBeforePadding = 1

SET @toReturn = RTRIM(LTRIM(@toReturn))
SET @returnStringLength = LEN(@toReturn)
IF @returnStringLength < @length

SET @toReturn = @toReturn + REPLICATE(@padCharacter, @length - @returnStringLength)
RETURN @toReturn
END
GO

View 8 Replies View Related

Why For SQL 2000 Max Row Size Can Not Be More Than 8060 Characters (Japanese) Nvarchar(4000)

Feb 7, 2007

I want the reason for the above statement where I user nvarchar(4000)
to insert the japanese text it give the same error , why we cannot have
maximum size ? if we can have maximum size than 8060 what is the
setting



Please help me ..

Thanks in anticipation



Ashish Tahasildar

View 4 Replies View Related

Compare Nvarchar(10) With Nvarchar(1000)

Sep 4, 2007

I had this question for quite a long time.

It seems the latter one don't take any extra storage space than the previous one.

As long as the real string length is less than 10.

Is that mean the latter one not cost anything?

I once heard the different is when they are in memory. But not sure of it.

Can anyone explain it and provide some official reference on it?

Thank.

View 6 Replies View Related

Displaying Fields Greater Than 255 Chars

Apr 29, 2001

I have a column of varchar(2000) but when I use it in a select statement I only get the first 255 characters displayed. (all the data is there as I can see different parts using substring) How do I get the complete column to display?

View 2 Replies View Related

All Text Fields Truncated To 255 Chars

Jun 25, 2006

Hi

I defined the following table in MSSQL 2000


sql Code:






Original
- sql Code





CREATE TABLE saved_query (
id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
name VARCHAR(32) NOT NULL,
query_text VARCHAR(2048) NOT NULL
)






 CREATE TABLE saved_query (      id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,      name VARCHAR(32) NOT NULL,      query_text VARCHAR(2048) NOT NULL)



and whenever I insert or update the query_text field, it's always truncated to 255 characters. Why? I clearly specified a larger field size. I also tried defining query_text as a "TEXT" but got the same result.

Thanks for any help


Ken

View 2 Replies View Related

SQL Server 2K Truncating Text Fields At 255 Chars

Jul 20, 2005

I'm running SQL Server 2K (sp3a) and when I run the following query (inquery analyzer):SELECT id, LEN(ForeignWord) as Length, ForeignWordFROM WordsWHERE Language ='Thai' and LEN(ForeignWord) > 300ORDER BY Length descI receive the following results:id Length ForeignWord------- ----------- -----------34756 445 เ&#35...truncated at 25534839 412 เ&#36...truncated at 25537613 350 โ&#35...truncated at 25537808 315 โ&#35...truncated at 25538140 315 โ&#35...truncated at 255(The ForeignWord field is defined as varchar(1000))Note that even though the server says that the lengths are in excess of255 characters, the results are all truncated at 255 characters.I read that SQL Server 6.5 and 7.0 had some issues related to nativeaccess versus OleDb or ODBC, but this is Server 2K patched with thelatest updates.Any idea why my varchar fields are being truncated?-- RickHere is my table definition:CREATE TABLE [Words] ([ID] [bigint] IDENTITY (1, 1) NOT NULL ,[Language] [varchar] (50) NOT NULL ,[Module] [int] NOT NULL ,[Lesson] [int] NOT NULL ,[EnglishWord] [varchar] (1000) NOT NULL ,[ForeignWord] [varchar] (1000) NOT NULL ,[Note] [varchar] (2000) NULL ,[Military] [tinyint] NOT NULL CONSTRAINT [DF_Table1_Military]DEFAULT (0),[Supplemental] [tinyint] NOT NULL CONSTRAINT [DF_Table1_Supplemental] DEFAULT (0),[SoundFileName] [varchar] (1000) NULL)

View 4 Replies View Related

Excel Destination Errors For Fields &&> 255 Chars

Apr 13, 2007

Hi:

Am trying to write sql2005 data to Excel. I have problems when data length exceeds 255 chars. I used a sample destination file with cells containing >255 chars where required, so that the Excel Destination external column was recognized as DT_Text.

My oledb source columns(external and output) are both varchar (1000).

Works fine , but fails when values>255 chars.

Error 0xC0202009 on ProcessInput.



I use SQL2005 enterprise SP2.

I tried changing the Oledb source output to Textstream, but that does not work at all.



How do I export values >255 chars to excel?



TIA

Kar

View 7 Replies View Related

How To Compare Nvarchar(15), Char(5), And String

Jan 31, 2008

I have used a query statement with the following WHERE string to 'Fill'  a dataset.  
"AND (A.ApptsDate > '" & strApptPreDate & "' OR (A.ApptsDate = '" & strApptPreDate & "' AND A.ApptsTime >= '" & strApptPreTime & "' ))" & _ and strApptPreTime is defined as:Dim strApptPreTime As String = SomaShared.strPadTime(CStr(dApptCalcNewDate.Hour) + ":" + CStr(dApptCalcNewDate.Minute))
 
Somehow, the dataset showed only the ApptsTime after 10 am.  After more than 2 weeks of debugging, I still can see a dataset watch for > 10 amAppsTime only.   Now I am guessting, the problem is 9 is different from 10 - 16, it all because 9 is single digit.  Then I check the data type settings for these variables.  Here are what I found:
In SQL Server Agent job, the ApptsTime data was 'inserted' by @NewApptTimes, which is declared as char(5).In SQL Server database, the ApptsTime was defined as nvarchar(15).
My question are:     1. The reason why there were no 9 am data for the dataset, is becasue 9 am of nvarchar(15) is not > 8:30 of strApptPreTime?     2. If the answer to the quation 1 is yes, how do I define AppsTime and/or strApptPreTime?
 TIA,Jeffrey 

View 6 Replies View Related

Sorting Nvarchar Fields

Jun 6, 2007

Hi all,

I am having an issue which I'm guessing everyone has at one point. I just can't seem to find the answer. I might be misunderstanding something as I'm relatively new to SQL and data types etc.

Here is my issue.

I have a table with a column that has a nvarchar data type. The following is an example of field values in that column.

asystem1
zsystem19
zsystem9
bsystem23
bsystem3

I would like to sort that data alphabetically and then by number like so.

asystem1
bsystem3
bsystem23
zsystem9
zsystem19

A basic ORDER BY obviously will sort it alphabetically but will put 23 before 3. These system names are already named and can't be changed otherwise I would use "0" in front of single digit numbers.

I just can't figure out how to accomplish this. Is there a convert or cast (unfamiliar with those functions) that I can do or does it involve something more sophisticated?

I appreciate any help in advance.

Israel

View 6 Replies View Related

JDBC - Varchar Or Nvarchar Fields?

May 10, 2006

Hi, I'm starting a new application in java using JTDS jdbc driver(http://jtds.sourceforge.net) and SQLServer 2005 Express.I have to design the database from scratch and my doubt is if I have to usevarchar or nvarchar fields to store string data.Any experience about performance issues using nvarchar instead of varchar(considering that Java internally works in unicode too)?Thanks in advance,Davide.

View 4 Replies View Related

TSQL - Select First 3 Chars Where Not Special Chars

Feb 5, 2002

Say I have a column called 'NAME' in a table called 'CLIENT' and the values in NAME are Surnames or company names like:

NAME
----------------------
1-FOR-ALL
A.B. SMITH (TOOLS LTD)
BROWN
THOMSON
VW CAR SALES



I want my select to return the first 3 characters, excluding special characters (only characters between 1 and z).

In example, the following would be returned for the data above:

NAME
----------------------
1FO
ABS
BRO
THO
VWC

View 1 Replies View Related

TSQL - Select First 3 Chars Where Not Special Chars

Feb 11, 2002

Say I have a column called 'NAME' in a table called 'CLIENT' and the values in NAME are Surnames or company names like:

NAME
----------------------
1-FOR-ALL
A.B. SMITH (TOOLS LTD)
BROWN
THOMSON
VW CAR SALES



I want my select to return the first 3 characters, excluding special characters (only characters between 1 and z).

In example, the following would be returned for the data above:

NAME
----------------------
1FO
ABS
BRO
THO
VWC

View 1 Replies View Related

Non English Chars Are Being Shown As Junk Chars

Jan 9, 2008

Hi All

I have loaded some data to the application using flat files

which has non english chars.

all the columns in the database are NVARCHAR type.

but in db and in application UI, the non english chars are being diplayed as junk chars. ???121

The application supports UTF-8 format

is there any setting at db level to be modified to display the non english char set as is.

Thanks

View 2 Replies View Related

SQL- How To Compare Max Date Across Fields

Jan 4, 2006

Hello, I am wondering how to select the max date from a database view containing multiple date fields for a particular record. I am rusty at SQL and can't seem to get started. Here's an example of the data:

PRCL_IDPROJ_STRT_DTORD_DT ...
1242/3/20063/5/2006
5206/3/20068/2/2006
6412/31/2005
1872/14/20063/16/2006

I need to be able to compare the max date for each PRCL_ID record ("where prcl_id="). In the example above, prcl_id 124 has a max date of 3/5/2006, and prcl_id 520 has a max date of 8/2/2006, etc. The results of the SQL query should return the PRCL_ID and the max date.

Example query results:

PRCL_ID ORD_DT
124 3/5/2006

Please let me know if you can help or if I can provide more info.

Thanks,
Alexkav

View 6 Replies View Related

Compare Fields In 2 Tables

Jan 30, 2008

For example, I have 2 tables that have very similar fields

Table 1 Table 2
ShipRpt ShipRpt
invoice invoice
total sold total sold

Is it possible to compare each of these fields and return any record that has non matching data? I would join the tables on the shipping report or invoice and only compare the total sold field. If the invoices match and the total sold is different in each table, can I just return the 1 record?

View 2 Replies View Related

To Compare Fields Between Two Table

Jul 23, 2005

Hello,I would like to create a stored procedure that would compare the fieldsof two tables and their types. If they are different the user iswarned.How can I do that ?thx

View 3 Replies View Related

Compare Fields From Two Datasets

Jan 9, 2007

Hello,
How can I solve this problem.
For example, I have two databases. db1 and db2.
I want to compare two float fields from tables from db1 and db2 and the present the difference between these fields in a column in reporting services.

ex. loop1
value from db1.table_db1
4

value from db2.table_db2
6

diff
2

ex. loop2
value from db1.table_db1
2

value from db2.table_db2
2

diff
0

..continues...



Should I create 2 datasets and 2 datasources? Must I write custom code for this?

Regards






View 2 Replies View Related

Nvarchar Fields With Time Data - Calculate Difference In Hours

Sep 19, 2014

I have two nvarchar fields with time data 12:34:34 and the second one 12:34 I want to calculate the difference in Hours. The first field is called (OTIM) the second field is called (ReportedTime) if the name matters. I tried substring to trim the OTIM, I am unable to make it work.

View 3 Replies View Related

Cursor To Compare/report On The Same Fields In 2 Tables

Sep 20, 2006

I have the following cursor that I am comparing 2 tables, theproduction table and a copy of the production table, I want results ofall address's that are like the address1 field...the problem is...myresults are giving me every field and if there is more than one, it isputting it in a grid....I only want to see results if they are 1 for the same address fieldthis is what I have so far....declare @address1 char(61),@city char(61)declare address_cursor CURSOR FORSELECT address1,city FROM test.dbo.testaddOPEN address_cursorfetch next from address_cursor into @address1,@citywhile @@fetch_status = 0BEGINselect * from testadd where @address1 like '%' + address1 + '%' and@city = cityFetch next from address_cursor into @address1,@cityPrintENDCLOSE address_cursorDEallocate address_cursor

View 4 Replies View Related

Truncation Error: 255 Chars To 2 Chars.

Aug 27, 2007

Hi,

I am very new to using SSIS.

Trying to import data from MS Access 2000.

I receive the error "
[OLE DB Destination [1907]] Warning: Truncation may occur due to inserting data from data flow column "GENDER" with a length of 255 to database column "GENDER" with a length of 2. " on the source flow.

I have done some googling and came up with this post: http://torontosql.dotnetnuke-portal.com/Default.aspx?tabid=32233 which I thought may help, but it does not.

The query against the access datasource features the column: iif([sex]=1, 'm', 'f'). I tried using left(..., 2) as well, but SSIS is determind to treat the field as 255 characters for some reason.

I don't even particualrly care that the field is 255 chars and the sources is only two, I just want the data in! I have other fields coming up with similar error.

Can someone please advise?

PS, what is th significance of the "External Columns" Vs "Output Columns" on the Input and Output Properties tab in Advanced Editor?

I am really struggling with SSIS, it is not as intuitive as DTS.


View 1 Replies View Related

Rank Query - Compare 2 Total Income Fields?

Apr 24, 2015

I have a query that ranks. Once I get the ranked fields is there a way to compare the 2 total_income fields?

Here's the query:

select * from
(
select cardholderid, appcnum, total_income ,Rank() over (PARTITION BY A.APPCNUM
ORDER BY A.EFFSTARTDATE DESC) as Rank
from
TBL_EPIC_BILLSTATUS A
) tmp
where Rank in (2,3) and CARDHOLDERID = '704355'
--------------and rank ((2),total_income) <> rank (3),total_income))

Looking to do something like this to see if the income is different

View 17 Replies View Related

Compare Fields-two Flat Files-load Data

Jul 13, 2007

Hi All,



I am totally new to SSIS and im in the learing phase. I have a requirement as below,

I have two flat files (mainframe files), the structure i have given below,

File1:



070113

12345johnk

23456james



1st row is header record which has got date in YYMMDD format and remaining rows have emp no and emp name



File2:

070113

070113

070113

070113



contains 4 records which are dates.



The requirement is to compare the header date in file1 with the 4 dates in file2, if they are equal then it should load all the records in file1 except the header into a table and if they donot match then it should log an err msg. Please could someone provide a lead on this.



The files have same record length and fixed field delimited.



Thanks in advance

raj

View 1 Replies View Related

DB Engine :: Compare Two Tables And Log Difference In New Table With Fields?

Apr 21, 2015

I want to compare two tables and log the difference in new table with the fields as (old value,new value, column name). The column name should be the changes value column.

View 10 Replies View Related

Outlook 2003 Filter SQL Tab To Compare The Values Of Two Fields In A Given Contact.

Sep 28, 2007

Hello and Thank You in advance:


I would like to Use the SQL Tab in the Filter Selection of the View-Modify Current View Option in Outlook 2003.
I am specifically trying to create a statement that only displays those Contacts that have a Modified Date that is different than the Created date. In other words I want to view all the records that have been modified at any time after the date of their creation.

I have been unable to create a SQL statement that compares the Created and Modified fields in the Contacts. Would you please explain and show what the correct syntax is in order to compare the values of two fields within a given Contact?


These are all examples of what I have tried and that have not worked. I cannot find documentation for this anywhere only small articles here and there that are not enough for me to develop a complete answer from:

(("urnchemas:calendar:created" >= '1/1/2001 12:00 AM' AND
"urnchemas:calendar:created" <= '12/31/2001 12:00 AM')
AND ("urnchemas:calendar:created" <> "urnchemas:calendar:lastmodified" ))
("urnchemas:calendar:created" <> "urnchemas:calendar:lastmodified" )

(("urnchemas:calendar:created" >= '1/1/2001 12:00 AM' AND
"urnchemas:calendar:created" <= '12/31/2001 12:00 AM') AND
("DAV:getlastmodified" >= '1/1/2001 12:00 AM' AND
"DAV:getlastmodified" <= '12/31/2007 12:00 AM'))

("urnchemas:calendar:created" <> "DAV:getlastmodified")
("DAV:getlastmodified" <> "urnchemas:calendar:created")
("DAV:getlastmodified" <> 'urnchemas:calendar:created')
("urnchemas:calendar:created" <> 'DAV:getlastmodified')

View 2 Replies View Related

How To Accept More Than 4000 Characters?

Aug 3, 2007

 Hi all,I'm using MSSQL 2005, using the nvarchar(MAX) but it doesn't seems to take more than 4000 characters... Any idea why?Thank you,Kenny. 

View 6 Replies View Related

Fastest Way To Insert 4000+ Records

Nov 14, 2007

I'm writing a program that allows users to upload a csv file.  This file is then seperated into 4 datatables based on certain criteria then each datatable is uploaded into my database.  I'm essentially adding new rows to the datatables then running an update command on each using a tableadapter.  The problem is that these csv files can be large and can end up with 4000+ new records being added to the database and the update commands take a while to do it.  I've sat for about five minutes on one run while it updated.  I put in some time variable to see where all the time is spent and it takes only seconds to parse the data and seperate into the datatables, but minutes on the update commands.  Is there a more efficient way to insert this much data?

View 4 Replies View Related

Problem When I Try To Send More Then 4000 To Database

Dec 19, 2004

Hi

I have Problem When I try To Send More Then 4000 char To SQL Server Database !!!

I have Create Windows Application that Send data To SQL Server Database in Web Server .. But When I try To Send More Then 4000 char to (nText) Flied The data damaged

And also in the Remote database I cant Create Filed of (nVarChar) data type with length more then 4000 char

In another word
I cant Store More then 4000 char in filed of (nText) data type
And I cant Create (nVarChar) filed with more then 4000 char Length


Where is the problem ??
And How can I solve it

Thanks with my regarding

View 4 Replies View Related

Expressions Using Values Of More Than 4000 Characters

Mar 31, 2008

Is it not possible for expressions to work with variables that contain more than 4000 characters? I've heard of a limitation of expressions and 4000 characters, but I thought this meant that the expression itself cannot be more than 4000 characters -- not that the expression cannot work with values of more than 4000 characters.

For example, I have a two variables:

Test1 (type = String):
Value = [Some really long string whose length is > 4000 characters]

Test2 (type = String, EvaluateAsExpression = True):
Expression = "-" + @[User::Test1] + "-"

Test2 throws the following error:

The variable User::Test1 contains a string that exceeds the maximum allowed length of 4000 characters.

Reading the variable "User::Test1" failed with error code 0xC0047100.

Why is there such a limitation when working with string values? This seems really restricting. Are there any possible workarounds?

Thanks in advance.
Jerad

View 5 Replies View Related







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