0

I am trying to do an update on a table in SQL Server 2008 R2, but the column writes only 8000 characters.

The column's datatype is set to text, but I have already tried to change to varchar(max) with no success.

I also used the cast('variable' as text) and cast('variable' as varchar(max)), also unsuccessfully.

When doing the same update by the SQL console (I made a response.write on the screen, copied and pasted it) or inserted more than 8000 characters manually, it works (through Microsoft Visual Studio).

sql_Up = "UPDATE ABVC_Eventos SET titulo_eve = '" & Strip(Evento) & "', cod_sup_eve = '" & Strip(cod_sup_eve) & "', cod_sup2_eve = '" & Strip(cod_sup2_eve) & "', texto_eve = CAST('" & Strip(texto_eve) & "' AS TEXT), WHERE id_eve = '" & Strip(Cod_Evento) & "'" 
set Rs_sqlUp = bco.Execute(sql_Up)

The 'Strip' function is for sanitization.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jairo Filho
  • 342
  • 5
  • 17
  • 3
    Repeat after me: I. will. never. again. build. SQL. like. that. - You **must** use parameterized queries under all circumstances. Please take a look here to learn [how to create and use query parameters in ASP Classic](https://stackoverflow.com/q/1092512/18771). After you have rewritten your code and the error still occurs, please update your question accordingly. – Tomalak Nov 22 '17 at 18:40
  • Yep... Sadly it's an old legacy system and I can not do much about it. – Jairo Filho Nov 22 '17 at 18:41
  • 1
    @JairoFilho in which case, you can’t do much to fix it. Sorry. – user692942 Nov 22 '17 at 18:44
  • 1
    @JairoFilho You can change the code, right? It's ASP, there is nothing that could stop you. So go and fix it. – Tomalak Nov 22 '17 at 18:44
  • I'll see if the client approves. Well, the client wants to migrate everything to PHP. I think I have one more argument now. Thanks guys! – Jairo Filho Nov 22 '17 at 18:49
  • 2
    @JairoFilho there is no quick fix, firstly you have to make sure the provider you are using in the connection string can support `NVARCHAR(MAX)` in the first place. See https://stackoverflow.com/a/3112421/692942. – user692942 Nov 22 '17 at 18:50
  • 2
    Possible duplicate of [Strange problem with nvarchar(max) fields and Classic ASP](https://stackoverflow.com/questions/3112093/strange-problem-with-nvarcharmax-fields-and-classic-asp) – user692942 Nov 22 '17 at 18:51

0 Answers0