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);
  댓글 수: 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 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