Declaring Variables

  • I have SQL 7.0.

    I would like to declare a variable as a text field if it's possible. If it is possible how do you do it? When I tried to use "DECLARE @email text" it said "The text, ntext, and image data types are invalid for local variables".

    If it's not then I would like to find out why when I delcare something as a varchar(7999) it only will let it get as big as 255 characters instead of 7999 characters.

    Here is how I'm trying to use it:

    DECLARE @email varchar(7999)

    SELECT @email='' select @email=@email+database.dbo.table.email+';'

    FROM database.dbo.table

  • Are you running your query from QA?

    If it is a case you should change settings on a menu:

    Query-Current Connection Option on Advanced Tab - Maximum Characters per column.

    Set it to the max so you would retrieve the correct value without cutting it off

  • quote:


    If it's not then I would like to find out why when I delcare something as a varchar(7999) it only will let it get as big as 255 characters instead of 7999 characters.


    The reason is a text data type is a pointer to the memory address in which the data resides. Varchar is the actual data itself.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • I'm using this in a step within a job. So when I use the varchar why is it I can't get the length to 7999?

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply