Æ´½ÓSQLÓï¾äµÄÎÊÌâ
SQL code:
declare @topCount int
select @topCount=10
declare @sql nvarchar(400)
set @sql=N'select top @topCount * from tb_company'
exec sp_executesql @sql
Incorrect syntax near '@topCount'.
Õâ¸öÎÊÌâÒªÔõô½â¾ö
Êä³ö²ÎÊýÐÎʽ
ÓÃSP_EXECUTESQLÖ´ÐÐ
SQL code:
declare @topCount int
select @topCount=10
declare @sql nvarchar(400)
set @sql=N'select top '+@topCount+' * from tb_company'
exec sp_executesql @sql
Ū´í
SQL code:
declare @topCount int
select @topCount=10
declare @sql nvarchar(400)
set @sql='select top '+@topCount+' * from tb_company'
exec (@sql)
SQL code:
set @sql=N'select top '+@topCount+' * from tb_company'
Ïà¹ØÎÊ´ð£º
´ó¼Ò°ïæ¿´¿´Õâ2¸ösqlÓï¾äÄĸö²éѯµÄËٶȸü¿ìµã¡£Ð»Ð»°ïæ¡£±È½Ï׿±¡£ÔÚ×öÐÔÄܲâÊÔ¡£
select * from
±íA LEFT OUTER JOIN ±íB ON (±íA.id || ' ' =±íB.id) ,±íC , ±íD, ±íE
WhereÆäËûÌõ¼þ
select * ......
±íÈçÏÂ
½ÌÊÒID ×ùλÊý ¿ªÊ¼Ê±¼ä ½áÊøÊ±¼ä 2009Äê1ÔÂ1ÈÕ 2009Äê1ÔÂ2ÈÕ 2009Äê1ÔÂ3ÈÕ
101 50 08£º00 08£º30 30 40 50
101 50 09£º00 ......
select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......
table1:
uID uName
1 СÀî
2 СÕÅ
table2:
pID uID type
1 1 H1
2   ......
±ía
Ïß·´úÂë Ïß·Ãû³Æ Main_ID
cir11 cirA 1
cir21 cirB 1
cir13 ......