MATLAB is not passing string type variable into SQL SERVER 2014

27 ビュー (過去 30 日間)
Usama Arshad
Usama Arshad 2016 年 3 月 10 日
コメント済み: Walter Roberson 2016 年 3 月 12 日
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);
  2 件のコメント
Usama Arshad
Usama Arshad 2016 年 3 月 12 日
its working. thanks alot :-)
Walter Roberson
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 ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by