.netѧϰ×ܽᣨ6£©Ö®sqlserver ×Ô¶¨Ò庯ÊýÓë´æ´¢¹ý³Ì
21 Ò»¸öSQLServerµÄ×Ô¶¨Ò庯ÊýÖе÷ÓÃÒ»¸ö×Ô¶¨ÒåµÄ´æ´¢¹ý³Ì£¬Ö´Ðд˺¯Êýºó·¢³öÈçÏÂÌáʾ£º“Ö»Óк¯ÊýºÍÀ©Õ¹´æ´¢¹ý³Ì²ÅÄÜ´Óº¯ÊýÄÚ²¿Ö´ÐÐ"¡£
ÔÒò£ºº¯ÊýÖ»ÄÜʹÓüòµ¥µÄsqlÓï¾ä,Âß¼¿ØÖÆÓï¾ä£¬¸´ÔÓÒ»µãµÄ´æ´¢¹ý³ÌÊDz»Äܵ÷Óõģ¬ÔÚº¯ÊýÀïÒ²²»ÄÜʹÓÃexecute sp_executesql »òÕßexecute ¡£½â¾ö·½·¨°Ñº¯Êý¸ÄΪ´æ´¢¹ý³Ì£¬È»ºóÔÚÁíÒ»¸ö´æ´¢¹ý³ÌÖÐÏóµ÷Óú¯ÊýÒ»ÑùʹÓô˴洢¹ý³Ì¾Í¿ÉÒÔÁË¡£
ÏÂÃæÊÇÒ»¸ö´æ´¢¹ý³Ìµ÷ÓÃÁíÒ»¸ö´æ´¢¹ý³ÌµÄʵÀý£¬ÓвÎÊý´«µÝµÄ¡£
--´æ´¢¹ý³Ìsp_B
create proc sp_B
@A int ,
@B int ,
@C int output
AS
set @C = @A + @B
go
--´æ´¢¹ý³Ìp_A
create proc sp_A
@A int ,
@B int
as
declare @C int
exec sp_B @A , @B , @C output
print @C
go
--²âÊÔ
exec sp_A 3 , 5
22. ÔõÑùÖ´Ðдø²ÎÊýµÄSQLÓï¾ä£¬±ÈÈç˵×Ö¶ÎÊÇÒ»¸ö²ÎÊý£¬ÈçºÎд´æ´¢¹ý³Ì£¿ÊµÀýÈçÏ£º
Create proc [dbo].[jsxs]
(
@zb varchar(5),
@nr varchar(4),
@ID int,
@shu int output
)
AS
BEGIN
declare @sqls nvarchar(1000)--×¢Òâ´ËÀàÐÍ
if @nr='A'
set @zb=@zb+'1'
if @nr='B'
set @zb=@zb+'2'
if @nr='C'
set @zb=@zb+'3'
if @nr='D'
set @zb=@zb+'4'
if @nr='E'
set @zb=@zb+'5'
----------------------------------Ö÷Ìⲿ·Ö------------------------------------
set @sqls='select @a=' +@zb + ' from shumu where peID=' +cast(@ID as char)
exec sp_executesql
@sqls,
N'@a int output',@sh
Ïà¹ØÎĵµ£º
È«ÎļìË÷ÊǶԴóÊý¾ÝÎı¾½øÐÐË÷Òý£¬ÔÚ½¨Á¢µÄË÷ÒýÖжÔÒª²éÕҵĵ¥´Ê½øÐнøÐÐËÑË÷£¬¶¨Î»ÄÄЩÎı¾Êý¾Ý°üÀ¨ÒªËÑË÷µÄµ¥´Ê¡£Òò´Ë£¬È«ÎļìË÷µÄÈ«²¿¹¤×÷¾ÍÊǽ¨Á¢Ë÷ÒýºÍÔÚË÷ÒýÖÐËÑË÷¶¨Î»£¬ËùÓеŤ×÷¶¼ÊÇΧÈÆÕâÁ½¸öÀ´½øÐеġ£ÏÂÃæ¾ÍÖð¸ö½éÉÜ¡£
¡¡¡¡½¨Á¢È«ÎÄË÷ÒýÖÐÓÐÁ½Ïî·Ç³£ÖØÒª£¬Ò»¸öÊÇÈçºÎ¶ÔÎı¾½øÐзִʣ¬Ò»Êǽ¨Á¢Ë÷ÒýµÄÊý¾Ý½á¹¹¡ ......
1.°²×°ºÃSQLServer 2005Êý¾Ý¿âÈí¼þ£¬½Ó×Å×îÖØÒªµÄ¾ÍÊÇ°²×°Êý¾Ý¿âÇý¶¯SQL Server 2005 driver for JDBC£¬¿ÉÒÔµ½:http://download.microsoft.com/download/8/B/D/8BDABAE2-B6EA-41D4-B903-7916EF3690EF/sqljdbc_1.2.2323.101_enu.exeÏÂÔØ
2.½«JDBC½âѹµ½ÈÎÒâµÄλÖã¬ÔÚ°²×°Ä¿Â¼ÀïÕÒµ½sqljdbc.jarÎļþ£¬ÒÔÇ°µÄÎÄÕÂÖÐÒѾ½²¹ ......
ÔÚƽʱµÄ¹¤×÷¹ý³ÌÖУ¬×÷ΪDBA½ÇÉ«¹ÜÀíÊý¾Ý¿â£¬Í·ÄÔÖеÄÓ¡ÏóÍùÍùÊÇÊý¾Ý¿âʵÀýÃû³Æ£¬¶ø²»»áÈ¥¹ØÐÄServerµÄIP£¬¶ø×÷ΪDeveloperµÄ½ÇÉ«£¬ËûÃÇÍùÍùÏëÖªµÀÖªµÀServer IpºÍ¶Ë¿ÚºÅ¡£ËùÒÔ£¬DBA»á¾³£±»Îʼ°µ½£ºXXXʵÀýµÄIPºÍ¶Ë¿ÚºÅÊÇʲô£¿
Õâ¸öÎÊÌ⣬µ±È»ÎÒÃÇ¿ÉÒÔLoginµ½OS²é¿´IP¡¢Ê¹ÓÃÅäÖƹÜÀí¹¤¾ß»ñÈ¡µ½¶Ë¿ÚºÅ¡£µ«ÊÇ£¬Õâ¸ö·½·¨·Ç ......
sqlserverÊý¾Ý¿â£ºjavaÁ¬½Ósqlserver2005Êý¾Ý¿âÐĵÃÌå»á
Ê×ÏȵÃÏÂÔØÇý¶¯³ÌÐòµ½Î¢ÈíÍøÕ¾ÏÂÔØMicrosoft SQL Server 2005 JDBC Driver 1.2¡¡¡¡½âѹMicrosoft SQL Server 2005 jdbc driver1.2.exe
µÃµ½sqljdbc.jar£¬ÓõÃʱºòÖ±½Ó¼Óµ½classpathÖÐÈ¥.
¡¡ÉèÖÃSQL Server·þÎñÆ÷
·ÀÖ¹³öÏÖ
com.mi ......
µ±ÔÚC#ÓïÑÔÖУ¬Á¬½ÓsqlÊý¾Ý¿âµÄʱºò£¬³£Óõ½sqlconnection½¨Á¢ÓëÊý¾Ý¿âµÄÁ¬½Ó¡£ Óï·¨ÈçÏ£º
String sqlcon = "***";//ÕâÀïÊÇÒ»¸ö×Ö·û´®£¬¾ßÌå¸úÊý¾Ý¿âµÄÑéÖ¤·½Ê½Óйء£
//sql server Éí·ÝÑéÖ¤ Á¬½Ó×Ö·û´®
private string ConnstrSqlServer = "server=·þÎñÆ÷Ãû³ ......