MATLAB is not passing string type variable into SQL SERVER 2014
31 次查看(过去 30 天)
显示 更早的评论
abc = 'abcdef';
conn = database('databasename','user id','password',...
'Vendor','Microsoft SQLServer', 'Server', '(local)', 'AuthType', 'Server', 'portnumber', 1433);
query = 'INSERT INTO table_Name (column_Name) VALUES (abc)';
curs = exec(conn,query );
close(curs);
close(conn);
0 个评论
采纳的回答
Walter Roberson
2016-3-10
query = sprintf( 'INSERT INTO table_Name (column_Name) VALUES (''%s'')', abc);
2 个评论
Walter Roberson
2016-3-12
%s is a string format specifier for the sprintf() call. sprintf() is like fprintf() but returns the output to a string.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String Parsing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!