Re: Update string too long?

From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 02/15/05


Date: Mon, 14 Feb 2005 22:32:48 -0500


> And we won't question to reason for this routine as you asked...
>

That is going to be hard, but since you promised :)

-- 
----------------------------------------------------------------------------
Louis Davidson - drsql@hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design - 
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in 
consulting services.  All other replies may be ignored :)
"David Gugick" <davidg-nospam@imceda.com> wrote in message 
news:%23bABxpwEFHA.2572@tk2msftngp13.phx.gbl...
> Sue wrote:
>> Hello.
>>
>> I need to take information from several columns, delimit the values
>> with commas, and put the results in another column.  I am using joins
>> etc to filter only the rows to update.  When I do something like:
>>
>> UPDATE dbo.MSP_TASKS
>> SET dbo.MSP_TASKS.EXT_EDIT_REF_DATA = '1, ' +
>> CAST(dbo.MSP_TASKS.TASK_ACT_WORK AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_WORK AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_REM_WORK AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_DUR AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_ACT_DUR AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_REM_DUR AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_START_DATE AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_FINISH_DATE AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_CONSTRAINT_TYPE AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_CONSTRAINT_DATE AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_ACT_START AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_ACT_FINISH AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_STOP_DATE AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_RESUME_DATE AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_PCT_COMP AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_COST AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_FIXED_COST AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_ACT_COST AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_LEVELING_DELAY AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_PCT_WORK_COMP AS VARCHAR(30)) + ', ' +
>> CAST(dbo.MSP_TASKS.TASK_FIXED_COST_ACCRUAL AS VARCHAR(30))
>> FROM         dbo.MSP_PROJECTS INNER JOIN
>>                      dbo.MSP_TASKS
>> ON dbo.MSP_PROJECTS.PROJ_ID = dbo.MSP_TASKS.PROJ_ID
>>
>> WIth this script, I am getting NULL in the
>> dbo.MSP_TASKS.EXT_EDIT_REF_DATA column.  I am using the CAST
>> statement because it wasn't allowing me to join the values otherwise.
>> I did discover that if i do not use all the columns(fields?) It does
>> the update fine.  I have tried reducing the VARCHAR values, but it
>> isn't enough.  Another point is that from code (PHP for this part I
>> believe), the update works just fine.  I am just trying to run this
>> once for now, but would like to make this a stored procedure for
>> future programming needs.
>>
>> Sorry if this question is so simple that I should have been able to
>> find the solution elsewhere.  Also if I didnt use the terminology
>> correctly.  I am only trying to get this resolved, not to be judged
>> for what I don't know yet. This board/newsgroup/discussion group is a
>> bit intimidating.
>
> We are all sweet.
>
> If any of those columns have a NULL value when concatenating, you'll get 
> NULL in the final column.
>
> Select 'n' + 'u' + 'l' + null -- This returns NULL
>
> To prevent this add an ISNULL() function around each column and set the 
> second parameter to '' (quote-quote).
>
> BTW, what is the data type and length for the 
> dbo.MSP_TASKS.EXT_EDIT_REF_DATA column you are inserting into? Can it 
> support the full length of the inserted data?
>
> And we won't question to reason for this routine as you asked...
>
> -- 
> David Gugick
> Imceda Software
> www.imceda.com 


Relevant Pages

  • Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
    ... simplest combination that mimics the compilation/linker problem. ... One obvious reason for this _MIGHT_ be you're not compiling the module which now contains that routine whereas before it was included in a different source file so got compiled transparently. ... You can place the dummy function in a module but keep it simple--the point is to simply duplicate the outline of the problem to uncover the reason for confusing the linker or why the piece is missing, _not_ to make a working application at this point. ...
    (comp.lang.fortran)
  • Re: get HelpContextIDs or Tags of all userforms
    ... I haven't tried the large routine you recently posted but I had tried the ... >>> For some reason I have to run the Sub twice to get the Form names in ... >> see an obvious reason for any errors at all, ... >> Dim bDebug as boolean ...
    (microsoft.public.excel.programming)
  • RE: Identity/Seed Values
    ... is not a substitute for this. ... SQL Server doesn't change the IDENTITY value ... IDENTITY yourself except by deleting and then inserting a row (another reason ... why you shouldn't tie external meaning to an arbitrary IDENTITY value). ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL 2005 Password Expiration
    ... New error codes ... Reason: Password change failed. ... password does not meet policy requirements because it is too short. ... Mike Epprecht, Microsoft SQL Server MVP ...
    (microsoft.public.sqlserver.security)
  • Re: vb.net after update to DB, I cant load stored thumbs
    ... Dim abyt() As Byte = ... I'm creating an app that uses a SQL server to store 100X100 thumbnail images ... The thumbnails are stored in an Image datatype in sql SErver. ... LoadImagesFromDB routine, it works fine! ...
    (microsoft.public.dotnet.languages.vb)