Skip to main content

Posts

Showing posts from June, 2014

sp_MsForEachTable - compare data between tables

usually i will using temporary table to build dynamic query to compare the value for two indentical database between two servers but few weeks ago i know undocumented sp_msforeachtable stored procedure and gain some advantage for using it exec sp_MSforeachtable  @command1 = ' IF EXISTS( SELECT top 1 * FROM [server2].db_name.? EXCEPT  SELECT top 1 * FROM ?   ) PRINT ''?'' ' just make sure u use "." in first syntax because sp_msforeachtable return "dbo.table_name" for parameters reference please see this link see u

create ClickOnce shortcut at Startup

currently there are needs to add some shortcut based on ClickOnce Application that being deployed, it's obvious we can't create it manually because of the installation path here is some remedy :D, u need to add reference to System.Deployment, System.IO,  System.Reflection  if (ApplicationDeployment.IsNetworkDeployed) { string publisherName = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute), false)).Company; string productName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); startupPath = Path.Combine(startupPath, productName) + ".appref-ms"; if (!File.Exists(startupPath)) { string allProgramsPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs); string shortcutPath = Path.Combine(allProgramsPath, publisherName); shortcutPath = Path.Combine

Find all Database size in SQL Server

hi, just came across a very good script from Pinal Dave u can see all database information in one place here the script SELECT database_id, CONVERT(VARCHAR(25), DB.name) AS dbName, CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'status')) AS [Status], state_desc, (SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS DataFiles, (SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS [Data MB], (SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'log') AS LogFiles, (SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'log') AS [Log MB], user_access_desc AS [User access], recovery_model_desc AS [Recovery model], CASE compatibility_level WHEN 60 THEN '60 (SQL Server 6.0)' WHEN 65 THEN '65 (SQL Server 6.5)' WHEN 7