SQLÉú³ÉÁ÷Ë®ºÅ
¾¹ýÁ˼¸´ÎµÄ²âÊÔÖÕÓڳɹ¦ÁË
declare @Year Int,
@Month int,
@Day int,
@Temp_No varchar(12),
@NeedNo varchar(4),
@No varchar(20),
@Number varchar(50),
@RandNo varchar(50),
@Nu varchar(10)
select @year=Year(GetDate())
select @Month=Month(GetDate())
select @Day=Day(GetDate())
select @No=Str(@Year,4,0)+
(select
case
when @Month>=10 then Str(@Month,2,0)
when @Month<10 Then '0'+Str(@Month,1,0)
end)+
(select
case
when @Day>=10 then Str(@Day,2,0)
when @Day<10 Then '0'+Str(@Day,1,0)
end)
select @Number =Idd from lsh
select @Nu=count(*) from lsh
if @Nu ='0'
BEGIN
select @No=@No+'0001'
END
else
BEGIN
SELECT @RandNo = STR(CONVERT(int,(SUBSTRING(@Number ,9,4))+1),4,0)
&nb
Ïà¹ØÎĵµ£º
SQLÓï¾äÓÅ»¯¼¼Êõ·ÖÎö
²Ù×÷·ûÓÅ»¯
IN ²Ù×÷·û
ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ׶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£
µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊDZȽϵ͵ģ¬´ÓORACLEÖ´ÐеIJ½ÖèÀ´·ÖÎöÓÃINµÄSQLÓë²»ÓÃINµÄSQLÓÐÒÔÏÂÇø±ð£º
¡¡¡¡¡¡ORACLEÊÔͼ½«Æäת»»³É¶à¸ö±íµÄÁ¬½Ó£¬Èç¹ûת»»²»³É¹¦ÔòÏÈÖ´ÐÐINÀïÃæµÄ×Ó²éѯ£¬ ......
SQL SERVER 2005 ͬ²½¸´ÖƼ¼Êõ
ÒÔÏÂʵÏÖ¸´ÖƲ½Ö裨ÒÔ¿ìÕÕ¸´ÖÆΪÀý£©
ÔËÐÐƽ̨SQL SERVER 2005
Ò»¡¢×¼±¸¹¤×÷£º
1£®½¨Á¢Ò»¸ö WINDOWS Óû§£¬ÉèÖÃΪ¹ÜÀíԱȨÏÞ£¬²¢ÉèÖÃÃÜÂ룬×÷Ϊ·¢²¼¿ìÕÕÎļþµÄÓÐЧ·ÃÎÊÓû§¡£
2£®ÔÚSQL SERVERÏÂʵÏÖ·¢²¼·þÎñÆ÷ºÍ¶©ÔÄ·þÎñÆ÷µÄͨÐÅÕý³££¨¼´¿ÉÒÔ»¥·Ã£©¡£´ò¿ª1433¶Ë¿Ú£¬ÔÚ·À»ðǽÖÐÉèÌØÀ ......
sql="select * from (select top 4 ID,SmallPic,NewsNameSi,EndDate,ContentSi,SortID from achi_news where ProductProperty=1 and IsOk=1 and HomeForcePage=1 and HomeEndTime>getDate() and isdate(HomeEndTime)=1 order by HomeorderNum asc )a union all select * from (select top 4 ID,SmallPic,NewsNameS ......
µ÷ÊÔSQLÊý¾Ý£¬·¢ÏÖÊý¾Ý¼Ç¼¼¯Öظ´ÎÊÌ⣬ËùÒÔ£¬¼ÆËã³öµÄÊý¾Ý½á¹û±¶ÊýÎÊÌ⡣ͨ¹ýµ÷ÊÔSQL£¬·¢ÏÖÊÇÎïÁϵķÖÀà²úÉúÖظ´£»Ö®ËùÒÔ²úÉúÖظ´£¬ÎïÁϵķÖÀà±ê×¼²»Ò»Ñù£¬Óëʵ¼ÊµÄÒµÎñÓйء£³ÌÐòÖÐÒ»Ö±ÓÃÀà±ðÀ´Çø·ÖÀà±ð£¬¶øÕâÕÅ´Îʵ¼ÊÒµÎñ²»ÐèÒªÓëÀà±ðÓйأ¬ËùÒÔ£¬Ã»ÓжÔÓ¦µÄ¹ýÂËÌõ¼þ£¬ËùÓеÄÀà±ðÈ«²¿Ñ¡³öÀ´ÁË¡£È»ºó£¬°ÑÏÂÃæµÄºìÉ«×Ö¶Î×¢ ......
[SQL SERVER] ¿ç·þÎñÆ÷²éѯ
[SQL SERVER] ¿ç·þÎñÆ÷²éѯ
·½·¨Ò»:
ÓÃOPENDATASOURCE
ÏÂÃæÊǸö¿çSQLServer²éѯµÄʾÀý
Select TableA.*,TableB.* from OPENDATASOURCE(
'SQLOLEDB',
'Data Source=ServerA;User ID ......