set @sql=n'select @oogoodscount=sum(tstoredecstored.frescount) from tstoredecstored
inner join tstoredecstorem on (tstoredecstored.fstoredecstoremid = tstoredecstorem.fstoredecstoremid)
where tstoredecstorem.fbilldate between '''+@ibdate+''' and '''+@iedate+''' and tstoredecstored.fresid='+ cast(@resid as varchar)
exec sp_executesql @sql,n'@oogoodscount float output',@oogoodscount output
SQL語句中加中括號的作用
在操作sqlserver資料庫的時候,經常能看到用中括號 括住的字段,這些字段可能是表名或者欄位名等等。那麼為什麼要加中括號呢?解釋如下 為了防止某些關鍵字在使用中引起歧義,如果加上中括號,則代表這是乙個欄位名,而不是關鍵字。例如 表中有乙個欄位叫select,而select是sql中的乙個關鍵字,...
case語句中定義變數要加括號
map iterator it map iterator itid recv acceptsocket,char recvbuf,sizeof recvbuf 0 switch recvbuf.protocol if it m muserpassword.end break case load it...
swtich和case語句中,定義變數要加花括號
switch是我們做條件選擇時,經常用到的乙個語句。一直以來對於他的使用相信大家也都是得心應手,前幾天在linux下寫乙個c 程式時遇到了這樣的乙個問題,請看例子 include using namespace std int main int i cout i switch i case 0 in...