sqlÈ¡²éѯֵ
ÈçÌ⣺select name from table1
µÃµ½½á¹û£ºname
СÍõ
СÕÔ
СÀî
СÖÜ
ÏëÒª½á¹û£º
°Ñ²éѯµ½µÄ½á¹û¸³Öµ¸ø@SQL
ÔÖ°£º@sql='admin'
ÏëÒª½á¹û£º@sql=@sql+',СÍõ£¬Ð¡ÕÔ£¬Ð¡ÀСÖÜ'
×¢£º¾¡Á¿²»Òªdo..whileÑ»·
ÔÚÏߵȣ¬Ó⻶®µØ·½Çë˵£¡
¶¥¶¥
declare @sql varchar(500)
select @sql='admin'
select @sql=@sql+','+name from table1
print @sql
ÎÊÌâ»ù±¾½â¾ö£¬¿ÉÊÇ [tabel]±íÊDZäÁ¿£¬²»È·¶¨
¸ÃÈçºÎ
SQL code:
declare @table1 nvarchar(50)
set @table1 = '****'
...
exec 'select @sql = @sql + '',''+ name from @table1'
...
ѧϰ
ÄǾÍÏñÎÒÃÇÒ»°ãº¯ÊýÑùµÄ
Ïà¹ØÎÊ´ð£º
sql table±íÓиöÎı¾ÀàÐ͵Äa×ֶΣ¬´æ´¢µÄÄÚÈÝÈ«²¿ÊÇÊý×Ö£¬ÀýÈç2009001£¬2008578ÕâÑùµÄ¸ñʽ£»b×Ö¶ÎÎı¾ÀàÐÍ£¬´æµÄÒ²ÊÇÊý×ÖÀýÈç 001£¬123
aspÀïÃæ strday=100£¬strb=001
ÎÒÏë¶Á³ö£¬´Óa×ֶεÄÊý×Ö°´´óµ½Ð¡µÄË ......
ÏÖÔÚÓÐÁ½¸öÒì¹¹µÄsql serverÊý¾Ý¿â,ÎÒÏ뽫µÚÒ»¸ö±íÖеÄÊý¾Ýµ¼Èëµ½µÚ¶þ¸ö±íÖÐ,×Ô¼ºÖ¸¶¨µ¼ÈëÊý¾ÝµÄ×Ö¶Î,ÈçºÎµ¼ÈëÊý¾ÝÄØ,´ó¼ÒÌÖÂÛÒ»ÏÂ?
dts¹¤¾ß
µ¼Èëµ¼³ö¹¤¾ß.
DD
¹þ¹þ£¬¹À¼ÆÕâλÊǵØQIOU¶¼Êܲ»Á˵Ä
Ö±½ÓÐ ......
СµÜÊǸöÐÂÊÖ ÏÖÔÚÓиöÎÊÌâÒ»Ö±²»Äܽâ¾ö
ÀýÈç
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
±íÖÐÊÇÕâÑù£¬
²¿ÃźŠ²¿ÃÅÐÅÏ¢
1 ²¿ÃÅÒ»
2 ²¿ÃŶþ
3 ²¿ÃÅÈý
4& ......
³ÌÐòʱASP+access
sql="select top 2 id,username from comp order by rnd(id) "
ÉÏÃæÓï¾äˢкó¶¼ÊÇÒ»¸öÖµ ÕâÑù»¹ÓÐËæ»úµÄÒâÒåÂð
ACCESSÓÐË¢ÐÂËæ»úÑ¡ÔñµÄSQLÓ ......