all groups > sql server programming > december 2005 >
You're in the

sql server programming

group:

Varchar limitation on 8000 problem in SQL Server 2000


Re: Varchar limitation on 8000 problem in SQL Server 2000 David Gugick
12/8/2005 2:44:10 PM
sql server programming: [quoted text, click to view]

A bigger problem is this:

a.. FOR XML is not valid in subselections, whether it is in UPDATE,
INSERT, or DELETE statements, a nested SELECT statement, or other
statements (SELECT INTO, assignment). For example, subselects as shown
in these examples are not supported:
Example A

SELECT *
FROM Table1
WHERE ......(SELECT * FROM Table2 FOR XML RAW)
Example B

DECLARE @doc nchar(3000)
SET @doc = (SELECT * FROM Customers WHERE CustomerID = 'ALFKI' FOR XML
RAW)See here for more
information:http://www.sqlxml.org/faqs.aspx?faq=104

--
David Gugick
Quest Software
www.imceda.com
www.quest.com
Re: Varchar limitation on 8000 problem in SQL Server 2000 JT
12/8/2005 4:55:50 PM
A VarChar will only store 8000 bytes maximum, but you could try whatever
with data type Text.

Perhaps XML is not the best way to store this type of object in the
database. In the past, I've implemented loging triggers similar to below.
The relational data is more compact and easier to query.

create table Employee
(
AuditDate datetime,
AuditType char(1),
Id int identity,
Name varchar(100)
)

CREATE trigger EmployeeAudit on Employee
AFTER INSERT, UPDATE, DELETE
AS
insert into EmployeeAudit select getdate(), 'D', * from deleted
insert into EmployeeAudit select getdate(), 'I', * from inserted


[quoted text, click to view]

Varchar limitation on 8000 problem in SQL Server 2000 Henrik Skak Pedersen
12/8/2005 8:03:02 PM
Hi,

I have a problem with varchar(8000) in my trigger. It is a big problem for
me that the X and Y variables below are limited by 8000 characters, how can
I make them larger?

I can illustrate it like this:

Create database AuditTest
Create table Audit (
AuditId int identity,
deletedText text,
insertedText text
)

create table Employee (
Id int identity,
Name varchar(100)
)

CREATE trigger EmployeeAudit on Employee
AFTER INSERT, UPDATE, DELETE
AS
DECLARE @X VARCHAR(8000)
select @x = (SELECT * from deleted for xml auto, elements) --,
xmlschema)
DECLARE @Y VARCHAR(8000)
select @Y = (SELECT * from inserted for xml auto, elements) --,
xmlschema)
INSERT INTO Audit
values(@x, @y)

Thanks Henrik

Re: Varchar limitation on 8000 problem in SQL Server 2000 Henrik Skak Pedersen
12/8/2005 10:15:22 PM
Yes, You are right, that is why I am trying to copy the xml into a variable
before inserting .

[quoted text, click to view]

Re: Varchar limitation on 8000 problem in SQL Server 2000 Henrik Skak Pedersen
12/9/2005 12:00:00 AM
Hi JT,

Thank you for you reply.

That was my backup plan :-)

I have to audit a lot of tables and send the result to a message query like
function. Therefore i thought that this would be better. But of couse if
there is a limitation on 8000 it will be impossible.

[quoted text, click to view]

AddThis Social Bookmark Button