If you get this error:
Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Try installing Framework .NET 3.5 SP1. It usually bring problems when passing to production since VS 2008 brings this version and the version on the production server sometimes is not fully up to date.
Friday, April 3, 2009
Wednesday, January 21, 2009
How to truncate the log file in SQL Server
There might have happened that you needed to truncate the log file because the server run out of space, but no matter what you do, you don't get that log file truncated in SQL Server.
To truncate the log file, you need to run the two following command in this same order:
BACKUP LOG database_name WITH TRUNCATE_ONLY
DBCC SHRINKFILE(database_log, 10)
Where database_name is the name of the database you want the log to be truncated. The database_log is the logical name of the log you need to truncate. The last parameter is the number of MB you need the log to be reduced to, in this case is to be reduced to 10 megabytes.
If you are not sure about the log name, check it through the Microsoft SQL Management Studio (usually going to the properties of the database, option Files).
There is a big note on this procedure though, be careful when you do this, because you will loose most of the information in the log. It is always recommended to make regular backups (complete backups if possible) to avoid loosing information.
To truncate the log file, you need to run the two following command in this same order:
BACKUP LOG database_name WITH TRUNCATE_ONLY
DBCC SHRINKFILE(database_log, 10)
Where database_name is the name of the database you want the log to be truncated. The database_log is the logical name of the log you need to truncate. The last parameter is the number of MB you need the log to be reduced to, in this case is to be reduced to 10 megabytes.
If you are not sure about the log name, check it through the Microsoft SQL Management Studio (usually going to the properties of the database, option Files).
There is a big note on this procedure though, be careful when you do this, because you will loose most of the information in the log. It is always recommended to make regular backups (complete backups if possible) to avoid loosing information.
Monday, January 19, 2009
How to change identity value in SQL Server
Sometimes you will need to change the next identity value of a primary key in SQL Server. It might be because you wiped out the table and want to start counting from one or because you want to force it to start counting from an specific value.
There are two ways to do this. The first one is changing the value through the Microsoft SQL Server Management Studio:
1. Right click the table and select the option to modify the table.
2. Then change the value directly into the editor and save the table modification.
There are two ways to do this. The first one is changing the value through the Microsoft SQL Server Management Studio:
1. Right click the table and select the option to modify the table.

2. Then change the value directly into the editor and save the table modification.

The other option to change the identity value is running the following query:
dbcc checkident('mytablename', reseed, 0)
Where mytablename is the name of the table you want to reseed. The last parameter '0' (zero) is the previous value of the next value you want to create. In this case, the next insert will insert 1 as the primary key. If you use for example 49, the next insert value will be 50.
Saturday, January 17, 2009
Select stored procedures and function names from SQL Server
In addition to my previous post, within the same sysobjects table you should be able to find the names of the Stored Procedures and the Functions from a SQL Server database by running the following query.
Query for stored procedure names:
select [name],[crdate] from dbo.sysobjects where xtype='P'
Query for function names:
select [name],[crdate] from dbo.sysobjects where xtype='FN'
Query for stored procedure names:
select [name],[crdate] from dbo.sysobjects where xtype='P'
Query for function names:
select [name],[crdate] from dbo.sysobjects where xtype='FN'
Thursday, January 15, 2009
Select table names in SQL Server
The following query will give you a list of the table names of a database in SQL Server. Note that this is a query done directly into the sysobjects which is not recommended for production purposes, but it could get you out of problems if you need the table names from the database.
The query is:
select [name] from dbo.sysobjects where xtype='U'
If you are curious enough, you will see that you should be able to get the Creation Date too:
select [name],[crdate] from dbo.sysobjects where xtype='U'
Simple, easy and straight to the point. :D
The query is:
select [name] from dbo.sysobjects where xtype='U'
If you are curious enough, you will see that you should be able to get the Creation Date too:
select [name],[crdate] from dbo.sysobjects where xtype='U'
Simple, easy and straight to the point. :D
Subscribe to:
Posts (Atom)