¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨
¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨
1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
eg: Select * from tableName
Exec('select * from tableName')
Exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
eg:
declare @fname varchar(20)
set @fname = 'FiledName'
Select @fname from tableName -- ´íÎó,²»»áÌáʾ´íÎ󣬵«½á¹ûΪ¹Ì¶¨ÖµFiledName,²¢·ÇËùÒª¡£
Exec('select ' + @fname + ' from tableName') -- Çë×¢Òâ ¼ÓºÅÇ°ºóµÄ µ¥ÒýºÅµÄ±ßÉϼӿոñ
µ±È»½«×Ö·û´®¸Ä³É±äÁ¿µÄÐÎʽҲ¿É
declare @fname varchar(20)
set @fname = 'FiledName' --ÉèÖÃ×Ö¶ÎÃû
declare @s varchar(1000)
set @s = 'select ' + @fname + ' from tableName'
Exec(@s) -- ³É¹¦
exec sp_executesql @s -- ´
Ïà¹ØÎĵµ£º
1.¡¸¿ªÊ¼¡¹²Ëµ¥->ÔËÐÐ
--Æô¶¯sql server 2005 ·þÎñ
net start mssqlserver
--Í£Ö¹sql server 2005 ·þÎñ
net stop mssqlserver
2.¡¸¿ªÊ¼¡¹²Ëµ¥->³ÌÐò->Microsoft SQL Server 2005->ÅäÖù¤¾ß
SQL Server Configuration Manager->SQL Server(MSSQLSERVER) ÓÒ»÷ Æô¶¯·þÎñ³É¹¦ºó£¬×´Ì¬ÏÔʾΪ“ÕýÔÚÔËÐ ......
ÔÚ¸ø¸÷ºÏ×÷ѧУ°²×°Ó¦ÓÃϵͳ¹ý³ÌÖУ¬·¢ÏÖѧУÀïµÄSQL SERVER 2000Êý¾Ý¿âËð»µÁËÖØ×°ºó¶¼·¢ÉúÁËͬÑùµÄÎÊÌ⣬ÄǾÍÊÇ°²×°SQL SERVERÊý¾Ý¿â²»³É¹¦¡£ÔÒò£º¼´Ê¹Äãͨ¹ý¿ØÖÆÃæ°åÀïµÄ“Ìí¼Ó/ɾ³ý³ÌÐò” Õý³£µÄжÔØSQL SERVERÊý¾Ý¿â£¬µ«ÊÇ£¬SQL SERVER»¹ÊÇûÓÐÍêȫжÔظɾ»£¬»¹ÐèÒªÊÖ¹¤½øÐÐһЩ²Ù×÷¡£Òò´ËÖØа²×°²»³É¹¦£¬º ......
ÅäÖÃÔ´³ÌÐò
¸½¼ÓÊý¾Ý¿âSQL Server 2005
£¨1£©½«TM\01\App_DataÎļþ¼ÐÖеÄdb_SIS.mdfºÍdb_SIS_log.ldfÎļþ¿½±´µ½SQL Server 2005°²×°Â·¾¶ÏµÄMSSQL.1\MSSQL\DataĿ¼Ï¡£
£¨2£©Ñ¡Ôñ¿ªÊ¼/³ÌÐò/Microsoft SQL Server 2005/SQL Server Management StudioÏ½øÈëµ½“Á¬½Óµ½·þÎñÆ÷”Ò³Ã棬Èçͼ1.1Ëùʾ¡£
ͼ1.1&nbs ......
1.°´ÐÕÊϱʻÅÅÐò: Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.Êý¾Ý¿â¼ÓÃÜ: select encrypt('ÔʼÃÜÂë') select pwdencrypt('ÔʼÃÜÂë') select pwdcompare('ÔʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ
3.È¡»Ø±íÖÐ×Ö¶Î: declare @list varchar(1000),@sql nvarchar(1000)&n ......
import java.io.*;
import java.sql.*;
public class DBConn {
private String ADDRESS ;
private int PORT ;
private String DBNAME ;
private String USERNAME ;
private String PASSWORD ;
private Connection conn ;
private PreparedStatement pstmt ;
pri ......