摘要:--for 2005 select * from sys.index_columns where object_id = object_id('MyTable') --for 2000 and 2005 select * from sysindexkeys where id = object_id('MyTable') 参考MSDN: http://msdn.microsoft.com/...
阅读全文
随笔分类 - SQL Server
SQL Server 2000, 2005, 2008相关的学习资料.
摘要:--for 2005 select * from sys.index_columns where object_id = object_id('MyTable') --for 2000 and 2005 select * from sysindexkeys where id = object_id('MyTable') 参考MSDN: http://msdn.microsoft.com/...
阅读全文
摘要:C#代码: SqlConnection conn = new SqlConnection("Data Source=192.168.1.200;Initial Catalog=PBCRM;Persist Security Info=True;User ID=sa;Password=123456"); conn.Open(); SqlTrans...
阅读全文
摘要:declare @null varchar(1); set @null = null; if (@null is null) begin print 'is null always works not matter "ANSI_NULLS" variable '; end set ANSI_NULLS OFF if (@null = null) begin print '...
阅读全文
摘要:exec msdb.dbo.sp_send_dbmail @recipients= 'rockniu@gmail.com', @copy_recipients = 'rock.niu@axisoft.com.hk', @profile_name = 'PBCRM_Mail_Account', @subject = 'Database ...
阅读全文
摘要:在运行窗口输入regedit,打开注册表编辑器,在HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager中找到PendingFileRenameOperations,删除该键值(这个键值是安装程序暂挂项目,只要找到对应的应用程序清除掉就行了),关闭注册表编辑器。重新安装SQL Server 2000即可。
阅读全文
摘要:SELECT o.name AS "Table Name", i.rowcnt AS "Row Count" FROM sysobjects o, sysindexes i WHERE i.id = o.id AND i.indid IN(0,1) AND o.xtype = 'u' --只统计用户表 AND o.name 'sysdiagrams' ORDER BY i.rowcnt DESC...
阅读全文
摘要:今天在调试一个sqlcommand的超时问题,为了不改原有的代码,我在最前面加了一个waitfor,搞定! WAITFOR TIME '10:20'; --10:20分开始执行后面的代码 另一种写法: WAITFOR DELAY '00:00:31'; --31秒钟后执行后面的代码
阅读全文
摘要:SQL Server 2005的安全的确提高了不少,普通用户运行一个BULK INSERT和OpenRowSet都要授权。 要执行BULK INSERT,只需要授予用户bulkadmin权限,但如果要执行OpenRowSet,默认情况下只有sysadmin权限才行的。 “不行,我们不会让系统以sa权限运行,这样很不安全,”,我们的银行客户说。 在网上找了半天,无解!天无绝人之路,查了下MS...
阅读全文
摘要:EXECUTE sp_msforeachtable 'delete from ?' 或者 EXECUTE sp_msforeachtable 'truncate table ?'
阅读全文
摘要:方法1: 第一步: backup log DATABASE_NAME with no_log 第二步: 收缩特定数据库的所有数据和日志文件,执行 dbcc shrinkdatabase (DATABASE_NAME) 方法2: 另一种方法有一定的风险性,因为SQL SERVER的日志文件不是即时写入数据库主文件的,如处理不当,...
阅读全文
摘要:首先,打开sql server的高级选项开关: EXEC sp_configure 'show advanced options', 1 RECONFIGURE 再打开shell执行开关: EXEC sp_configure 'xp_cmdshell', 1 RECONFIGURE 执行你想要的exe程序: exec xp_cmdshell 'c:\Holleworld.exe' 安全期...
阅读全文
|