Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    21

    Unanswered: Transact SQL - local variable

    I execute the following in my Query Analyzer:

    Declare @Test varchar(8000)

    Set @Test='SELECT VIOXX_LastName + '' + VIOXX_FirstName + '' + CONVERT(varchar(50), VIOXX_Number) AS PlaintiffsName, VIOXX_Number
    FROM tblPlaintiff WHERE VIOXX_Number NOT IN(SELECT VIOXX_Number FROM tblCase_Plaintiff) OR
    VIOXX_Number IN (SELECT tblCase_Plaintiff.VIOXX_Number FROM tblCase INNER JOIN tblCase_Plaintiff ON tblCase.Case_Number = tblCase_Plaintiff.Case_Number
    WHERE (tblCase.Status = ''InActive'')) ORDER BY VIOXX_Number, VIOXX_LastName'
    Select @Test

    and get the following result:
    SELECT VIOXX_LastName + ' + VIOXX_FirstName + ' + CONVERT(varchar(50), VIOXX_Number) AS PlaintiffsName, VIOXX_Number
    FROM tblPlaintiff WHERE VIOXX_Number NOT IN(SELECT VIOXX_Number FROM tblCase_Plaintiff) OR
    VIOXX_Number IN (SELECT

    the latter part of my original text is not stored in the variable. Is there some limitation on the number of characters for a local variable in transact sql?

    Any ideas? Thanks in advance.

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    If you are using QA - check settings for results tab and set up 8000.

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    A result set has a limit on the width of each column. The default width is 255 characters, which is what I think is truncating your displayed value.

    From Query Analyzer, you can:
    1) Press shift-ctrl-o for options
    2) Click the Results tab
    3) Click in the Maximum characters per column control (on the right, about 1/3 of the way down)
    4) Type in a good guess at your widest column (these are expensive in the GUI, don't be extravegant).
    5) Click Ok
    6) Re-run your query with the new parameters.

    -PatP

Posting Permissions

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