SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Pipe Symbol as Column delimiter


Pipe Symbol as Column delimiter

Author
Message
Sara_DBA-629440
Sara_DBA-629440
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 93
I need pipe sysmbol as column delimiter., eg.,

FirstName | LastName | Address | Phone

Can anyone explain me how to do this (except +'|'+ option) please? I used +Char(166)+ and export into .dat file. When I open into notepad the sysmbol is different but it is opening in DOS prompt / editor w00t

I need this .dat file should open in notepad also with '|' symbol.

Thanks in advance...Your help is much appreciated...

Sara

A ship in the harbour is safe . . . but that's not what ships were made for. BigGrin
Sara_DBA-629440
Sara_DBA-629440
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 93
Lately I found CHAR(124) will be the Pipe Symbol (|)

Thanks for your timings...BigGrin

Sara

A ship in the harbour is safe . . . but that's not what ships were made for. BigGrin
Sara_DBA-629440
Sara_DBA-629440
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 93
I am exporting records by using Stored procedure. The master table contains many coulmns, I needed to export all master table columns (10 columns) into .dat file,

eg of the master table.,

Column names: FirstName, LastName, Address, Phone, Pin

so all these result set sould be pipe delimited in the .dat file.,

SELECT ISNULL(FirstName,'') + CHAR(124) + ISNULL(LAstName,'')+ CHAR(124) +ISNULL(Address,'')+ CHAR(124) +ISNULL(Phone,'') from table.

Thanks

Sara

A ship in the harbour is safe . . . but that's not what ships were made for. BigGrin
Sara_DBA-629440
Sara_DBA-629440
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 93
I tried initially and now but the result is same (-t| -r\r)

"The system cannot find the path specified"

Sara

A ship in the harbour is safe . . . but that's not what ships were made for. BigGrin
Sara_DBA-629440
Sara_DBA-629440
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 93
I checked and found command should be '-c -T -t "|" '

eg.,

'BCP ' + @TABLE + ' QUERYOUT ' + @DIR + @FILE + '-c -T -t "|" '

Thanks for your help.

Sara

A ship in the harbour is safe . . . but that's not what ships were made for. BigGrin
er_ramirez20-1032551
er_ramirez20-1032551
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 9
Thanks!!!
That works for me. Adding "|" in the line.

Regards
hrothenb
hrothenb
SSC Rookie
SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)

Group: General Forum Members
Points: 37 Visits: 64
--Generate BCP DOS command to export pipe delimited data.

DECLARE @BCPCommandString VARCHAR(8000)
DECLARE @FilePath VARCHAR(1000)
DECLARE @FileName VARCHAR(1000)
DECLARE @SPName VARCHAR(1000)
DECLARE @ServerName VARCHAR(1000)
DECLARE @tSQL VARCHAR(1000)

SET @ServerName = 'myServer'
SET @tSQL = 'Select top 10 * from myTable'
SET @FilePath = 'C:\temp\'
SET @FileName = 'myFileName.tmp'

SET @BCPCommandString = 'bcp "' + @tSQL + '" queryout ';

SET @BCPCommandString = @BCPCommandString + @FilePath + @FileName;

SET @BCPCommandString = @BCPCommandString + ' -S ' + @ServerName;

SET @BCPCommandString = @BCPCommandString + ' -T -c -t^| -U username -P password';

SELECT @BCPCommandString;



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search