Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:23:27+00:00 2026-05-26T20:23:27+00:00

I use text data type in one of my tables and also I use

  • 0

I use text data type in one of my tables and also I use PIVOT with the query too.
I am unable to use MAX(AttributeValue) where AttributeValue is the type of text. It returns the following error Operand data type text is invalid for max operator.. How can I use it here, because I am imposed to use an aggregate function with PIVOT.

Edit:
I followed the post http://msdn.microsoft.com/en-us/library/ms187993.aspx

I tried to convert the data type to nvarchar(max).

ALTER TABLE dbo.MyTable
ALTER COLUMN AttributeValue NVARCHAR(MAX)

Also I have to use Full Text Search option too. I get the following error
Cannot alter or drop column 'AttributeValue' because it is enabled for Full-Text Search.

SELECT 
 [6B93119B-263B-4FED-AA89-198D26A3A3C4] DOB
,[F1A0D9D6-702E-4492-9EBC-63AD22E60E6A] CaseTitle 
FROM MyTable PIVOT 
(   MAX(AttributeValue) 
    FOR AttributeID IN 
    (
         [6B93119B-263B-4FED-AA89-198D26A3A3C4]
        ,[F1A0D9D6-702E-4492-9EBC-63AD22E60E6A]
    ) 
) ResultTable

Where the ‘AttributeValue’ is of ‘text’ data type. I get the following error,

Operand data type text is invalid for max operator.

Well, I tried to cast the field to nvarchar(max). It gives another type of error(in the fourth line).

Incorrect syntax near '('

Did I miss anything ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:23:28+00:00Added an answer on May 26, 2026 at 8:23 pm

    You can cast your text column to varchar(max).

    select max(cast(AttributeValue as varchar(max)))
    from YourTable
    

    You can convert your data in a sub query.

    SELECT 
     [6B93119B-263B-4FED-AA89-198D26A3A3C4] DOB
    ,[F1A0D9D6-702E-4492-9EBC-63AD22E60E6A] CaseTitle 
    FROM ( SELECT AttributeID, 
                  CAST(AttributeValue as VARCHAR(MAX)) as AttributeValue
           FROM MyTable
         ) AS T
      PIVOT 
    (   MAX(AttributeValue) 
        FOR AttributeID IN 
        (
             [6B93119B-263B-4FED-AA89-198D26A3A3C4]
            ,[F1A0D9D6-702E-4492-9EBC-63AD22E60E6A]
        ) 
    ) ResultTable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use data binding to display values in text boxes in a C# Windows
I want to use echo to add data into a text file progressively. I
What exactly will happen to the data segment and text segment if I use
I have three tables. Two use a foreign key that pulls in data and
I'm generating T-SQL SELECT statements for tables for which I have no data type
I often use THEAD, TBODY, and TFOOT elements to divide my data tables into
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
use Text::Diff; for($count = 0; $count <= 1000; $count++){ my $data_dir=archive/oswiostat/oracleapps.*dat; my $data_file= `ls
use Text::Diff; my $count; our $stats2 = 0; for($count = 0; $count <= 1000;
What is the difference to use {text-decoration: underline} and {border-bottom: ...} ? which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.