Skip to main content

Posts

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...

Force Application update in ClickOnce deployment

the key is to set minimum requirement version to be exactly like the one u published right now to remove the update popup dialog when starting clickonce program just make sure the version is the same between Publish version and Update the Project properties - Publish until then

WCF: The underlying connection was closed

hi, just got an error for couple of days when try to return a model contain child record using Entity Framework and DBContext i have this Role class that contain list of User within that Role so when i try to get specific Role along with the User it give me an error "The underlying connection was closed " after searching alot i came up with this great solution disabled proxy creation and lazy loading or  manually in Entity DBContext constructor it run succesfully and can return UserInRole but if i filled up the table then the error comes, so we need to  Preserving Object Reference in WCF  but i came with this very useful  Andrey Chabster Blog  that using custom attribute that needed for the Service contract and Operation contract  until then