¶¯Ì¬SQL»ù±¾Óï·¨
Select * from tableName
exec('select * from tableName')
exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
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 -- ´Ë¾ä»á±¨´í
declare @s Nvarchar(1000) -- ×¢Òâ´Ë´¦¸ÄΪnvarchar(1000)
set @s = 'select ' + @fname + ' from tableName'
exec(@s) -- ³É¹¦
exec sp_executesql @s -- ´Ë¾äÕýÈ·
3. Êä³ö²ÎÊý
declare @num int, @sqls nvarchar(4000)
set @sqls='select count(*) from tableName'
exec(@sqls)
--ÈçºÎ½«execÖ´Ðнá¹û·ÅÈë±äÁ¿ÖУ¿
declare @num int, @sqls nvarchar(4000)
set @sqls='select @a=count(*) from tableName '
exec sp_executesql @sqls,N'@a int output',@num output
select @num
1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ Àý: Select * from tableName
Exec('select * from tableName')
Exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
´íÎó: declare @fname varchar(20)
set @fname = 'FiledName'
Select @fname from tableName  
Ïà¹ØÎĵµ£º
SQLÓï¾äÏÈǰдµÄʱºò£¬ºÜÈÝÒ×°ÑһЩÌØÊâµÄÓ÷¨Íü¼Ç£¬ÎÒÌØ´ËÕûÀíÁËÒ»ÏÂSQLÓï¾ä²Ù×÷£¬·½±ã×Ô¼ºÐ´SQLʱ·½±ãÒ»µã£¬ÏëÌùÉÏÀ´£¬Ò»Æð¿´¿´£¬Í¬Ê±Ï£Íû´ó¼ÒÄܹ²Í¬¶à¶àÌáÒâ¼û£¬Ò²¸øÎÒÁôһЩ¸üºÃµÄ¼Ñ¾ä£¬ÕûÀíÒ»·Ý¡¶¾«ÃîSQLËÙ²éÊֲᡷ£¬²»Áߴͽ̣¡
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾ ......
QT DataBase SQL Explorer
1¡¢°²×°MySQLµ½¹Ù·½ÍøÕ¾ÏÂÔØMySQLÊý¾Ý¿â£¬·Ç°²×°°æ£¬Ö±½ÓÔËÐÐmysqld½ø³Ìǰ̨µÄ
2¡¢Ìí¼Óϵͳ»·¾³±äÁ¿£¬Path+=':\mysql\bin'µÄpath£¬ÔÙÔÚ¿ªÊ¼ÔËÐУ¬CMD->mysql -uroot µÇ¼µ½mySQLÊý¾Ý¿â
Default passwordûÓеģ¬ÓеĻ° mysql -uroot -pÊäÈëÃÜÂ룻ÍøÂçµÇ¼£ºmysql -h ip ......
winform주
//´æ´¢
private void MemoryImage()
{
string sql = "";
&nbs ......
SQL ÃüÁî
Õⲿ·Ö°üº¬ÄÇЩ PostgreSQL Ö§³ÖµÄ SQL ÃüÁîµÄÐÅÏ¢£®ÕâÀïµÄ "SQL" ¾ÍÊǸÃÓïÑÔͨ³£µÄº¬Ò壻 ÿÌõÃüÁîµÄÓë±ê×¼ÓйصļæÈÝÐÔµÄÐÅÏ¢¿ÉÒÔÔÚÏà¹ØµÄ²Î¿¼Ò³ÖÐÕÒµ½£®
Table of Contents
ABORT -- Í˳öµ±Ç°ÊÂÎñ
ALTER GROUP -- Ïò×éÖÐÔö¼ÓÓû§»ò´Ó×éÖÐɾ³ýÓû§
ALTER USER -- ¸Ä±äÊý¾ ......
×î½üÒ»Ö±ÔÚѧϰSQL serverµÄÄÚÈÝ¡£×òÌ쿼ÁËÒ»ÏÂÊÔ¡£¸Ð¾õÕæµÄÊDz»ÈÝÒ×°¡¡£ÌرðÊÇһЩ¸´ÔӵIJéѯ¡£¸ãµÃÎÒÍ·»èÄÔÕ͵ġ£²»¹ýÒ²ÊÇÓÉÓÚ×Ô¼ºµÄ֪ʶÕÆÎյĻ¹²»¹»Ôúʵ°¡¡£ËùÒÔ½ñÌ츴ϰÁËÒ»ÏÂT-SQlÓï¾äµÄÔöɾ¸Ä²é¡£·¢ÏÖµÄÈ·ÊÇÓкܶ඼Íü¼ÇÁË¡£ÏÖÔڰѽá¹ûд³öÀ´¡£ÒÔºó¿É²»ÒªÍüÁËѽ¡£
--SQLÓï¾ä¸´Ï° --Ò»,²åÈëinsertÓï¾ä --1,ins ......