Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Char(9) and Char(13)

Status
Not open for further replies.

mbde

Programmer
Mar 14, 2005
55
US
In SQL2000, When I try to insert char(9) or char(13) into a varchar field it gets treated as a space.

What I am trying to do is created a specific file format and return it in a field for a Access or C# app.

Here is some of the code

DECLARE @sText varchar(8000)
DECLARE @Tab CHAR(1)

SELECT @Tab = CHAR(9)

SELECT @sText = '1234' + @Tab
SELECT @sText = @sText + '134' + @Tab
SELECT @sText = @sText + REPLACE(CONVERT(VARCHAR(10), GETDATE(), 102), '.', '') + @Tab
SELECT @sText = @sText + REPLACE(CONVERT(VARCHAR(10), GETDATE(), 108), ':', '') + @Tab
SELECT @sText = @sText + CHAR(13)
SELECT @sText = @sText + (SELECT CONSTANT_VALUE FROM CONSTANTS WHERE CONSTANT_NAME = 'A_DUNS') + @Tab
SELECT @sText = @sText + (SELECT CONSTANT_VALUE FROM CONSTANTS WHERE CONSTANT_NAME = 'A_NAME') + @Tab
SELECT @sText = @sText + (SELECT CONSTANT_VALUE FROM CONSTANTS WHERE CONSTANT_NAME = 'B_DUNS') + @Tab
SELECT @sText = @sText + (SELECT CONSTANT_VALUE FROM CONSTANTS WHERE CONSTANT_NAME = 'B_NAME') + @Tab

SELECT @sText

I am trying not to do this in VB or C, because I want to keep the data is closer to the database. Instead of doing

(psedo code)

Dim s as string

Set rec = C.Execute(GetValues)

s = rec("A_Duns")

then
file.write s & vbTab

Does that make sense?

 
When you use the Query Analyzer, you won't notice special characters, but they are there.

After you write the data to a file, you'll see them.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top