![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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) |
![]() |
| Thread Tools | |
| Display Modes | |
| |