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'
...
ѧϰ
ÄǾÍÏñÎÒÃÇÒ»°ãº¯ÊýÑùµÄ
Ïà¹ØÎÊ´ð£º
СµÜÊǸöÐÂÊÖ ÏÖÔÚÓиöÎÊÌâÒ»Ö±²»Äܽâ¾ö
ÀýÈç
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......
'Select * into mytable from OpenDataSource(''Microsoft.JET.OLEDB.4.0'',''Data Source=f:\test.xls;Mode=Read;Extended Properties=Excel 5.0;Persist Security Info=False' ......
ÏÈÀ´Ò»¸ö´íÎóÓï¾ä¡£¡£
select * from [aa] where a1 in (select max(a2),a1 from [aa] group by a1 )
ÎÒ´óÌåÒâ˼£¬
¶Áȡһ¸öͳ¼ÆÏµÍ³ÖÐ ²»Öظ´µÄ IP °´ÕÕ ×îºóʱ¼äÅÅÐò£¬²¢ÏÔʾ³öËùÓÐ×ֶΡ£¡ ......
BeginTime BtsId Total68PhyRCENum
2009-9-30 0:00 1 192
2009-10-1 0:00 1 192
2009-10-2 0:00 1 192
2009-10-3 0:00 1 192
2009-10-4 0:00 1 256
2009-10-5 0:00 1 256
2009-10-6 0:0 ......