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

  • Home
  • SEARCH
  • 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 3962284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:04:41+00:00 2026-05-20T03:04:41+00:00

I am using a T-SQL block to get the dump of ascii characters stored

  • 0

I am using a T-SQL block to get the dump of ascii characters stored in a database column. I know this is accomplished easily in Oracle using the DUMP() function. I am not taht familiar with SQL Server sytax, but I am using something like this.

    SET NOCOUNT ON
-- Create the variables for the current character string position 
-- and for the character string.
DECLARE @position int, @string char(15), @output char(1000), @output2 char(2000)
-- Initialize the variables.
SET @position = 1
SET @output2 = 'Start:'
SELECT @string = name from 
location where location_type = 4405 and owner_id = 362
and location_id = 53183
WHILE @position <= DATALENGTH(@string)

       BEGIN
       SELECT @output = CAST(ASCII(SUBSTRING(@string, @position, 1)) AS CHAR)
        + ' ' +      CHAR(ASCII(SUBSTRING(@string, @position, 1)))
        PRINT @output
        --SET @output2 = @output2 + '=' + @output
        SET @position = @position + 1
       END
        --PRINT @output2 
    SET NOCOUNT OFF
    GO

For some reason if I uncomment the code that relates to @output2, it won’t print @output2 correctly.
The idea is to get all the ascii values returned as a single line instead of getting a line for each character. Am I doing something wrong?

  • 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-20T03:04:41+00:00Added an answer on May 20, 2026 at 3:04 am

    Change the data types for @output and @output2 to varchar. Replace DataLength with Len. Char is fixed length and does not grow when you add strings at the end of the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL Server 2000 and having a wierd issue with a SQL
I am executing a SQL Server 2000 DTS package using C# by following the
Started working with FluentMigrator today and unfortunately, I am pretty sure I know the
In my stored procedure I declared two table variables on top of my procedure.
I am using Django with memcached. In one of my templates, I added {%
I have several databases I'm managing, and each needs a copy of a particular
I'm having some trouble with my error handling in my ASP.NET MVC 2 application.
I'm part way through building a fairly complex HTML5 web app, that retrieves its
I have a web service written in PHP, that returns JSON results. It works

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.