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);

采纳的回答

Walter Roberson
Walter Roberson 2016-3-10
query = sprintf( 'INSERT INTO table_Name (column_Name) VALUES (''%s'')', abc);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by