Main | .NET and FireFox & Netscape »

How to compare db field of "text" data type?

Given a table with id which is auto number, category, description which is "text". How could I know if the database already have an identical record before I try to insert a new one?

Error Message:

The text, ntext, and image data types are invalid for local variables.

Testing Code:

declare @desc text
set @desc = 'description'

declare @cat_id int
set @cat_id = 21

if exists (select pid from position where cat_id = @cat_id and description = @desc)
print 'yes'
else
print 'no

TrackBack

TrackBack URL for this entry:
http://blog.lib.umn.edu/cgi-bin/mt-tb.cgi/17126

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)