string.format(“select Num ,name,type,{0} from jzy1308a12v“,c*ammout)
用string.Format string strUpdate = string.Format(@" update empattenceaudit set auditstate=1 where Yearmonth='{0}' and empid={1} and exists (select 1 from empattenceaudit where Yearmonth='{0}' and companyid={2} and coalesce(auditstate,0)=1 )", strYearMonth, EmpId, strCompany); 或者字符串直接拼接 string sqlgz = @"select SHEETID from TBLPAYLISTSHEET where YEARMONTH='" + findYearMonth + "' and WHETHERIMPORT=1";
string sql="select Num ,name,type,"+"'+c.ToString()+'"+"*ammout from jzy1308a12v";
select Num ,name,type,"+c+"*ammout from jzy1308a12v
select Num ,name,type,"+c+"*ammout from jzy1308a12v
declare @C INT EXEC('select '+@C+'=count(*) from '+@TableName)
string strUpdate = string.Format(@" update empattenceaudit set auditstate=1 where Yearmonth='{0}' and empid={1} and
exists (select 1 from empattenceaudit where Yearmonth='{0}' and companyid={2} and coalesce(auditstate,0)=1 )",
strYearMonth, EmpId, strCompany);
或者字符串直接拼接
string sqlgz = @"select SHEETID from TBLPAYLISTSHEET
where YEARMONTH='" + findYearMonth + "' and WHETHERIMPORT=1";
EXEC('select '+@C+'=count(*) from '+@TableName)