امير ميركمالي

Amir Mirkamali
166 - پیام , 203 - نظر

پیوندهای اصلی

اخبار

با تشکر از آقای مهندس طاهریان که در این مسیر، همواره راهنمای بنده بوده اند.
امیر میرکمالی

Check PageRank

بایگانی پیامها

بایگانی سال ۱۳۸۷

خرداد ۱۳۸۷، (۱)

بایگانی سال ۱۳۸۶

اسفند ۱۳۸۶، (۱)
بهمن ۱۳۸۶، (۱)
آذر ۱۳۸۶، (۱)
آبان ۱۳۸۶، (۵)
مهر ۱۳۸۶، (۲)
شهریور ۱۳۸۶، (۴)
مرداد ۱۳۸۶، (۲)
تیر ۱۳۸۶، (۲)
خرداد ۱۳۸۶، (۴)
اردیبهشت ۱۳۸۶، (۱۱)
فروردین ۱۳۸۶، (۴)

بایگانی سال ۱۳۸۵

اسفند ۱۳۸۵، (۲)
بهمن ۱۳۸۵، (۲)
آبان ۱۳۸۵، (۴)
شهریور ۱۳۸۵، (۴)
مرداد ۱۳۸۵، (۳)
تیر ۱۳۸۵، (۳)
خرداد ۱۳۸۵، (۱)
اردیبهشت ۱۳۸۵، (۸)
فروردین ۱۳۸۵، (۲)

بایگانی سال ۱۳۸۴

اسفند ۱۳۸۴، (۶)
بهمن ۱۳۸۴، (۷)
دی ۱۳۸۴، (۴)
آذر ۱۳۸۴، (۱۱)
آبان ۱۳۸۴، (۱۰)
مهر ۱۳۸۴، (۹)
شهریور ۱۳۸۴، (۵)
مرداد ۱۳۸۴، (۵)
تیر ۱۳۸۴، (۱۱)
خرداد ۱۳۸۴، (۲)
اردیبهشت ۱۳۸۴، (۱۰)
فروردین ۱۳۸۴، (۱۲)

بایگانی سال ۱۳۸۳

اسفند ۱۳۸۳، (۵)
بهمن ۱۳۸۳، (۲)

دسته بندی پیامها

(rss) ASP NET
(rss) ASP Net 2.0
(rss) General
(rss) Microsoft SQL Server

گالری عکسها

عکس های من


اخبار


دوستان و همکاران

Mirkamali
پایگاه اطلاع رسانی نمایشگاه ها، صنایع و تجارت ایران
پوریا
دعوت دوست
علیرضا محمدمیرزا
لغت نامه
کاراپرداز

رادکام

حمید طاهریان
شیما دهباشی
مجید اطلس باف
محسن طاهریان

۲۸ خرداد ۱۳۸۷

Set nowrap property in css

You change wrap property with white-space property in css.
normal : Default. White-space is ignored by the browser
pre : White-space is preserved by the browser. Acts like the pre tag in HTML
nowrap : The text will never wrap, it continues

زمان ارسال 9:45 صبح | نظرات (5)

۱ اسفند ۱۳۸۶

Empty All tables content in SQL Server

DECLARE @tableCatalog VARCHAR (1024) , 

@tableSchema VARCHAR (1024), @tableName VARCHAR (1024), @tableType VARCHAR (1024)
DECLARE cursorTemp CURSOR FOR
SELECT * FROM INFORMATION_SCHEMA.TABLES
OPEN cursorTemp
FETCH cursorTemp INTO @tableCatalog, @tableSchema, @tableName, @tableType


-- start the main processing loop.
WHILE @@Fetch_Status = 0
BEGIN
	EXEC (' ALTER TABLE '+@tableName+' NOCHECK CONSTRAINT ALL;' +
	' DELETE FROM '+ @tableName +';'+
	' ALTER TABLE '+@tableName+' CHECK CONSTRAINT ALL ') 
	FETCH cursorTemp INTO @tableCatalog, @tableSchema, @tableName, @tableType
END

CLOSE cursorTemp
DEALLOCATE cursorTemp

زمان ارسال 3:10 عصر | نظرات (0)

۱۶ بهمن ۱۳۸۶

Create ASP Net Website Administration Link

  • Create a virtual directory at the root of your default website
  • Name the virtual WebAdmin
  • Set the Path of the Virtual Directory to "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\ASP.NETWebAdminFiles" where 50215 is the appropriate build version for your installed .NET 2.0 framework.
  • After the Virtual Directory has been created, right click on the Virtual Directory and got to properties.  Select the ASP.NET tab and make sure the ASP.NET version is set to a 2.0 version.
  • Open a browser and browse to the following url:
    http://localhost/webadmin/default.aspx?applicationPhysicalPath=D:\wwwroot\timetracker\&applicationUrl=/Timetracker
  • Make sure to change the applicationPhysicalPath and applicationUrl querystring parameters to match whatever they are on your system.

زمان ارسال 12:07 عصر | نظرات (2)

۱۱ آذر ۱۳۸۶

FLV files don't work

If FLV files do not appear in the player and you get 404 error it means that you need to add a mime type for flv files.

add MIME-Type for .FLV extentions with the proper mime-type "flv-application/octet-stream

زمان ارسال 4:46 عصر | نظرات (0)

۲۹ آبان ۱۳۸۶

Kill all process related to database with T-SQL

CREATE TABLE #TmpWho
(spid INT, ecid INT, status VARCHAR(150), 
loginame VARCHAR(150), hostname VARCHAR(150),
blk INT, dbname VARCHAR(150), cmd VARCHAR(150))

INSERT INTO #TmpWho
EXEC       sp_who

DECLARE @spid INT     
DECLARE @getspid CURSOR     

SET @getspid = CURSOR FOR     
      SELECT       spid
      FROM      #TmpWho
      WHERE       dbname = 'YOURDBNAME'

OPEN @getspid     

FETCH NEXT FROM @getspid INTO @spid     

WHILE @@FETCH_STATUS = 0 
BEGIN
 KILL @spid --SELECT @spid works fine here
FETCH NEXT FROM @getspid INTO @spid
END
CLOSE @getspid 
DEALLOCATE @getspid 

DROP TABLE #TmpWho

زمان ارسال 8:52 صبح | نظرات (0)

How to Get ALL SQL Server process list?

just run sp_who stored procedure.

زمان ارسال 8:49 صبح | نظرات (1)

Set database to work in Single User or Multi User Mode

There are two ways :

  1. EXEC sp_dboption 'pubs', 'single user', 'TRUE'
  2. alter database pubs set SINGLE_USER  WITH ROLLBACK IMMEDIATE
To deactive single user mode :
  1. EXEC sp_dboption 'pubs', 'single user', 'FALSE'
  2. 2- alter database pubs set MULTI_USER 

زمان ارسال 8:43 صبح | نظرات (0)

۲۰ آبان ۱۳۸۶

Get Top n Row From DataTable or DataView

public DataView GetTopDataViewRows(DataView source, int count)
{
	DataTable output = source.Table.Clone();
	for (int i = 0; i < count; i++)
	{
		if (i >= source.Count)
			break;
		output.ImportRow(source[i].Row);
	}
	return new DataView(output, source.RowFilter, 
source.Sort, source.RowStateFilter); }

زمان ارسال 8:53 صبح | نظرات (1)

۷ آبان ۱۳۸۶

Altering a column on a Replicated Table

 

Sometimes the schema of a replicated table needs altering. There are many reasons this might be the case eg possibly the datatype has been incorrectly chosen, or a default is missing, or we want to rename a column. Attempting to change the table schema directly will result in the error 

"Cannot alter/drop the table 'tablename' because it is being published for replication". 

So, how to change an existing column without breaking replication? Consider if we wanted to make the following schema change:

to

The method we choose depends in part on the replication type and size of the table, but there are 2 main options: 

(a) altering the subscriptions

  exec sp_dropsubscription   @publication =  'tTestFNames' 
     ,  @article =  'tEmployees' 
     ,  @subscriber =  'RSCOMPUTER'
     ,  @destination_db =  'testrep' 
  

  exec sp_droparticle  @publication =  'tTestFNames'
     ,  @article =  'tEmployees'
  

  alter table tEmployees alter column Forename varchar(100) null
  

  exec sp_addarticle  @publication =  'tTestFNames' 
     ,  @article =  'tEmployees' 
     ,  @source_table =  'tEmployees' 
  

  exec sp_addsubscription  @publication =  'tTestFNames'
     ,  @article =  'tEmployees'
     ,  @subscriber =  'RSCOMPUTER' 
     ,  @destination_db =  'testrep' 
  
For snapshot replication this is the obvious choice. We drop the subscription to this article, drop the article, then change the table. Afterwards the process is reversed. The next time the snapshot agent is run, it'll pick up the new schema without any issues.

For transactional replication we may choose to proceed using the script above. However, we must be more careful in this case. By default, an insert, update or delete statement performed on the publisher is propagated to the subscriber in the form of a stored procedure call. By changing the column definition, we may need to change the related stored procedures on all the subscribers. Addition of a default would be fine, but changing the datatype itself as above would require the stored procedure arguments to be modified. For the example table above, these 3 procedures exist on the subscriber in the form: 

sp_MSins_tEmployees, 
sp_MSupd_tEmployees, 
sp_MSdel_tEmployees. 

They can be generated at the publisher using sp_scriptpublicationcustomprocs but this would of course require the system to be quiesced, i.e. during this (quick) change there shouldn't be any alterations made to the publisher's data and all the subscribers should be completely synchronized. 

This is not ideal, and there is also a hidden problem here waiting to be discovered. Usually, when you add a new article to an existing publication in transactional replication, running the snapshot agent will create a snapshot of just the new article. In our case, it'll also create a snapshot of the 'tEmployees' table. So, to avoid all the issues and complications mentioned above, it's simplest to run the snapshot agent immediately after executing sp_addsubscription and then synchronize.

In merge replication, there is no possibility of dropping the subscription on a per article basis using the script above, as there is in transactional and snapshot replication. If we drop the subscription entirely including all other articles (sp_dropmergesubscription), then try to run sp_dropmergearticle there will be an error if the snapshot has already been run, so we have to set @forceinvalid_snapshot to 1, make the table change on the publisher then read the article and subscriptions and initialize which would necessitate a new snapshot generation of all articles in this publication. A nosync initialization is possible, but this can be extremely restrictive for future changes, and I'll leave that for another article.

(b) altering the table in-place

OK, in some cases the table is large and we don't want to run a new snapshot - either of the individual table (transactional) or of the whole publication (merge) - so there is an alternative method. We might use the built in stored procedures sp_repladdcolumn and sp_repldropcolumn to make the changes (note that these procedures limit the subscribers to be SQL Server 2000 only). Using these procedures we can add a dummy column to hold the data, remove the old column, add in the correct definition of the original column then transfer back the data. Now the script becomes:
  exec sp_repladdcolumn  @source_object =  'tEmployees'
     ,  @column =  'TempForename' 
     ,  @typetext =  'varchar(100) NULL' 
     ,  @publication_to_add =  'tTestFNames' 
  

  update tEmployees set TempForename = Forename
  

  exec sp_repldropcolumn  @source_object =  'tEmployees' 
     ,  @column =  'Forename' 
  

  exec sp_repladdcolumn  @source_object =  'tEmployees'
     ,  @column =  'Forename' 
     ,  @typetext =  'varchar(100) NULL' 
     ,  @publication_to_add =  'tTestFNames' 
  

  update tEmployees set Forename = TempForename
  

  exec sp_repldropcolumn  @source_object =  'tEmployees' 
     ,  @column =  'TempForename'
    
Although the above script can be used for transactional replication or merge replication, the internal methodology is different due to the differing nature of these 2 techniques. For merge replication, details of the rows updated are kept in MSmerge_contents, and if a particular row has been changed once or a hundred times, there will still only be one entry in this system table, while in transactional replication, 100 updates to a row is propagated as 100 subscriber updates. This means merge has an advantage over transactional because we need to perform 2 updates to each row to make the schema change.

 

You can find the main article in: http://www.sqlservercentral.com/articles/Replication/alteringacolumnonareplicatedtable/1666/

 

 

زمان ارسال 4:34 عصر | نظرات (0)

۳۰ مهر ۱۳۸۶

Open New Window After Button Click and After running Server Side Code

Add your code in button click add this code (replace your link in the code)

 private void btn_Click(object sender, EventArgs e)
{

.....

 StringBuilder script = new StringBuilder();
script.Append("<script>");
script.AppendFormat("window.open('{0}', '', '');", link);
script.Append("</scri");
script.Append("pt>");
Page.RegisterStartupScript("opennewwindow", script.ToString());

.....

}

زمان ارسال 3:13 عصر | نظرات (2)