用SQL語句添加刪除修改欄位 1.增加欄位 alter table docdsp add dspcode char(200)2.刪除欄位 ALTER TABLE table_NAME DROP COLUMN column_NAME3.修改欄位類型 ALTER TABLE table_name ALTER COLUMN column_name new_data_type4.sp_rename 改名
1.對查詢進行最佳化,應盡量避免全表掃描,首先應考慮在 where 及 order by 涉及的列上建立索引。2.應盡量避免在 where 子句中對欄位進行 null 值判斷,否則將導致引擎放棄使用索引而進行全表掃描,如:select id from t where num is null可以在num上設定預設值0,確保表中num列沒有null值,然後這樣查詢:select id from t where num=03.應盡量避免在 where
==產生數字區間隨機數==--建立視圖 create view myview as select re=rand() --自訂函數:取得指定範圍的隨機數 create function mydata( @a int, @b int) returns decimal(38,0) as begin declare @r decimal(38,0) select @r=cast(re*(@b-@a)+@a as decimal(38,0)) from myview return(@r) end go
Database YourDB has full backup YourBaackUpFile.bak. It can be restored using following two steps.Step 1: Retrive the Logical file name of the database from backup.RESTORE FILELISTONLYFROM DISK = 'D:BackUpYourBaackUpFile.bak'GOStep 2: Use the values
SELECT sysobjects.name AS [table], sysproperties.[value] AS 表說明, syscolumns.name AS field, properties.[value] AS 欄位說明, systypes.name AS type, syscolumns.length, ISNULL(COLUMNPROPERTY(syscolumns.id, syscolumns.name, 'Scale'), 0) AS 小數位元,