|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 12:15 AM
Points: 244,
Visits: 300
|
|
Merry Holidays everyone, I've created a basic table which includes a text field. I then created a SP which basically read the text field and then added to the same field, the problem is I get an error that says I can't use TEXT or Varchar(Max), is there a way round this?
Table
CREATE TABLE KLN (RecId INT IDENTITY(1,1) PRIMARY KEY CLUSTERED, Dte DATETIME, machineid VARCHAR(50), Userid VARCHAR(50), memo text)
Stored Procedure
CREATE PROCEDURE [dbo].[Save_kln] @sDte as datetime, @smachineid as varchar(50), @sUserid as varchar(50), @smemo as text
AS DECLARE @sRESULTS varchar(MAX) if exists (select * from [kln] where [dte] = @sdte and Userid = @Suserid) begin set @sRESULTS = (select memo from [kln] where [dte] = @sdte and Userid = @Suserid) update [kln] set memo = @sRESULTS + @smemo where [dte] = @sdte and Userid = @Suserid end else begin INSERT INTO [kln] (dte,machineid,userid,memo) VALUES (@sdte,@smachineid,@suserid,@smemo) end
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 5:28 AM
Points: 37,735,
Visits: 30,005
|
|
You shouldn't be using TEXT in the first place, it's an old SQL 2000 data type, included only for backward compatibility. Use Varchar(max)
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 12:15 AM
Points: 244,
Visits: 300
|
|
GilaMonster (12/27/2012) You shouldn't be using TEXT in the first place, it's an old SQL 2000 data type, included only for backward compatibility. Use Varchar(max)
Varchar(Max) isn't allowed in my situation either
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 5:28 AM
Points: 37,735,
Visits: 30,005
|
|
Post your code with the varchar(max) used and post the exact error message
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 12:15 AM
Points: 244,
Visits: 300
|
|
| turns out what you suggested did work after all, I'd like to thank you for your help
|
|
|
|