Results 1 to 10 of 10

Thread: SQL Server

  1. #1

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    Question SQL Server

    Msg 402, Level 16, State 1, Line 1
    The data types text and varchar are incompatible in the equal to operator.
    What should I use instead?



    Thanks
    Another light-hearted post from Guru

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL Server

    What gives you that error?

    What are you trying to accomplish when you get it?

  3. #3
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: SQL Server

    You need to compare using 'LIKE', e.g.

    SELECT * FROM MYTable WHERE MyTextColumn LIKE 'Value'

  4. #4

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    Resolved Re: SQL Server

    Yay!
    Thanks again

    These may seem pretty simple questions but I very rarely use SQL Server; more familiar with Oracle really....


    Another light-hearted post from Guru

  5. #5

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    Question Re: SQL Server

    Next question:

    How do I a "group by" or "select distinct" on a text field?



    Thanks
    Another light-hearted post from Guru

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL Server

    What is your complete SELECT statement?

  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Server

    Why are you using TEXT fields?

    They have many limitations...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    Re: SQL Server

    select drive from tbldata group by drive


    select distinct drive from tbldata


    Typical values for drive would be:
    \\000.000.000.000\Apps (D)
    \\000.000.000.000\Data (E)
    \\000.000.000.000\System (C)



    What data type should be used instead of text?
    Another light-hearted post from Guru

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Server

    varchar(x) where x is some value for the max length.

    nvarchar() is for unicode data - doesn't appear that you have that requirement.

    text is for really large fields and has all kinds of limitations - as you have discovered.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  10. #10

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    Re: SQL Server

    OK thanks, I'll give it a go
    Another light-hearted post from Guru

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width