Ed Enstrom,
Thank!! just adding the '\r\n' as char characters did the trick.
Just had to add those in where I was building my string with out having do
to any substrings :)
SET @Users= '[USERS]' + char(13) + char(10)
+ 'First_Name=' + @FName + char(13) + char(10)
+ 'Last_Name=' + @LName + char(13) + char(10)
Nice to know you can add character values directly to a string, learn
something every day.
kapsolas
[quoted text, click to view] "Ed Enstrom" wrote:
> kapsolas wrote:
> > I am not sure if this is possible or not but I am trying to do the following.
> > I need to export data to a test file in the following format:
> >
> > [Users]
> > firstname=john
> > lastname=smith
> >
> > when Creating my table which stores this information, I am using T-SQL to
> > concatenate my values into one row, the row looks as follows
> > ROW1 => [Users] firstname=john lastname=smith
> > ROW2 => [Users] firstname=jane lastname=smith
> > ...
> > ROWN => [Users] firstname=user_N lastname = user_N
> >
> >
> > is there a quick way to get this information out of each row and onto a new
> > line when exporting to a text file?
> >
> > I'm really not sure at all how to approach this so any ideas would be
> > greatly appreciated.
> >
> > Thanks.
>
> Try this:
>
> select substring(ColumnName, CHARINDEX('firstname',ColumnName), CHARINDEX('lastname',ColumnName) -
> CHARINDEX('firstname',ColumnName)-1) + char(13) + char(10) + substring(ColumnName, CHARINDEX('lastname',ColumnName),
> len(ColumnName) - CHARINDEX('lastname',ColumnName) +1)
>