Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I am working on an application which requires a large data to be exported as XML or HTML, But the problem is i am getting an error-
SQL
Procedure expects parameter 'command_string' of type 'varchar'.
. So the question is are there any possibilities to override the procedure or some other way to do such thing.

Query is --
SQL
exec Master..XP_CMDSHELL 'echo "<html><head><style type="text/css">.login-wrapper {position: absolute;margin-top:15%;text-align: center;}.row-fluid {width: 100%;}.row-fluid:before, .row-fluid:after {display: table;line-height: 0;content: "";}.row-fluid:after {clear: both;}.row-fluid:before, .row-fluid:after {display: table;line-height: 0;content: "";}body {font-family: Open Sans , sans-serif;font-size: 12px;}body {font-family: "Lucida Console", Monaco, monospace;background-color: #f7f7f7;position: relative;font-size: 12px;padding: 0px;text-decoration: blink;width: auto;}.login-wrapper .box {margin: 0 auto;padding: 35px 0 30px;float: none;width: 500px;box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);border-radius: 5px;background: rgba(255, 255, 255, 0.65);}.row-fluid [class*="span"] {display: block;box-sizing: border-box;}.login-wrapper .box .content-wrap {width: 82%;margin: 0 auto;}div {display: block;}</style></head><body><div class="row-fluid login-wrapper"><div class="span4 box"><div class="content-wrap"><img alt="i.M. Branded" height="75px" src="" > C:\Users\atierp\Desktop\file.htm'



I need to export this file. It is static as of now but will be dynamic data.

Help would be very much appreciated.

Thanks,
Posted
Updated 11-Jun-13 4:41am
v3
Comments
Richard C Bishop 11-Jun-13 10:10am    
What that exception means is that the stored procedure you are calling is expecting "command_string" as a parameter in order for the stored procedure to run.

The only way to get around it, is to not call the stored procedure or change it to accept something else. A stored procedure does not really do you any good unless you can pass it data and have it return something else though, don't you think?
Richard C Bishop 11-Jun-13 10:12am    
Post the code you are using to and describe your goal and I bet your problem can be solved.
Ariana Bond 11-Jun-13 10:13am    
Yes you are correct that is why i have mentioned to override it or do something else for this.

1 solution

Again: what has this to do with xp_cmdshell?
Can you explain me, why do you want to use it, since it is meant for something totally different. It might look alike, but it is not a command shell you can should to do anything you can do in cmd.exe. Actually it is meant to start external processes. But not like that.
If you want just to write to a file on OS level, you have other tools.
See:
https://www.simple-talk.com/sql/t-sql-programming/reading-and-writing-files-in-sql-server-using-t-sql/[^]
http://www.nigelrivett.net/SQLTsql/WriteTextFile.html[^]
 
Share this answer
 
Comments
Ariana Bond 11-Jun-13 12:44pm    
Hey Zoltan,

First of all thank you very much for the suggestions, actually i have been to these portals but i didn't get how i can do this thing as every portal content mentioned to create a stored procedure to create a file but nowhere ,as per my search, the logic is mentioned either or may be i am unable to get it.If you can explain me how it is working then i'l be very thankful to you.
By the way thanks.
Zoltán Zörgő 11-Jun-13 14:34pm    
I don't get your problem. Your "query" in the post is writing a constant text to a constant file. I suppose this is not the real situation. What is the exact problem with the possibilities mentioned in the links I have given, they are really concrete?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900