January 6, 2023 at 3:01 pm
Hi All,
I am doing BCP out the table having 175 columns. For small table columns it works fine.
It errors out for this big column table.
EXECUTE master.dbo.xp_cmdshell 'bcp "SELECT col1...col175 FROM tbl123"
Msg 214, Level 16, State 201, Procedure master.dbo.xp_cmdshell, Line 1 [Batch Start Line 37]
Procedure expects parameter 'command_string' of type 'varchar'.
January 6, 2023 at 3:48 pm
We will need your help in order to be able to help you, so please help us!
😎
It would be greatly appreciated if you could provide the DDL (create table) script, sample data as an insert statement, the desired output from the sample data, and what you have tried so far.
January 6, 2023 at 3:54 pm
Hi All,
I am doing BCP out the table having 175 columns. For small table columns it works fine.
It errors out for this big column table.
EXECUTE master.dbo.xp_cmdshell 'bcp "SELECT col1...col175 FROM tbl123"
Msg 214, Level 16, State 201, Procedure master.dbo.xp_cmdshell, Line 1 [Batch Start Line 37] Procedure expects parameter 'command_string' of type 'varchar'.
You're missing some things in your command. You need to go back and read up on the BCP command. For example, you're not even identified which database it should read from. You're also missing the closing single quote, which is the cause of the "expects" error.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 7, 2023 at 2:45 am
Sorry, I just shown as example.
I am using STRING_AGG from INFORMATION_SCHEMA.columns and other system table to populate all the columns to BCP.
January 7, 2023 at 11:11 pm
I guess I don't understand why you think that you need to list every column. If you're trying to export the whole table, then export the whole table.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 9, 2023 at 4:34 am
I thought of using quotename. select * is not working some places found that because of CR LF.
January 9, 2023 at 5:53 am
I am not sure if this will help you. I had a similar situation with a table with large number of fields. I concatenated all the fields together to one text field using proper bcp command options. This seems to work fine.
I hope this helps.
DBASupport
January 9, 2023 at 10:00 am
I thought of using quotename. select * is not working some places found that because of CR LF.
select * does NOT CARE about CRLF - other than the thread you have with extracting data to load to MySQL do you have other extracts that truly require you to remove those from the data being exported?
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply