Microsoft SQL Server Links

Links, articles, scripts, tips, and other technical sources for managing SQL Server. DBALinks is dedicated to SQL Server and database administration.

CHECK OUR BLOGS!

 

 
BLOGS Minimize
Print  
 
SEARCH BLOGS Minimize

Print  
 
DOWNLOADS... Minimize
Print  
 
BOOKS... Minimize

Print  
 
Advertisement Minimize

 

Print  
 
Most recent blog entries
Msg 14650, Level 16, State 1, Procedure sp_send_dbmail, Line 68
Msg 14650, Level 16, State 1, Procedure sp_send_dbmail, Line 68 Service Broker message delivery is not enabled in this database. Use the ALTER DATABASE statement to enable Service Broker message delivery
Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Thursday, October 23, 2008

Truncating a data file

Truncating a data file

The following example truncates the primary data file in the AdventureWorks database. The sys.database_files catalog view is queried to obtain the file_id of the data file.

http://msdn2.microsoft.com/en-us/library/ms189493.aspx

USE AdventureWorks;
GO
SELECT file_id, name
FROM sys.database_files;
GO
DBCC SHRINKFILE (1, TRUNCATEONLY);

Comments (0)
Aleksandar Tosic's Blog Database Files By Aleksandar Tosic on Wednesday, October 15, 2008

Out of memory error when try to preview report

These are good links when getting error "Out of memory"  when running report in Reporting Service 2005.

 

http://msdn2.microsoft.com/en-us/library/ms156002.aspx

http://blogs.msdn.com/lukaszp/archive/2007/01/31/how-to-diagnose-issues-when-running-reports-in-the-report-server.aspx

 

 

Comments (0)
Aleksandar Tosic's Blog Reporting Services 2005 By Alex on Wednesday, October 15, 2008

How to generate a random number in SQL Server

 

To genereate a random number in SQL Server we can use random function.  Check example below where a random generated number is between 1 and 100:

select rand()
select rand() * 100
select cast(rand() * 100 as int) as number

 

Comments (0)
Aleksandar Tosic's Blog T-SQL By Alex on Wednesday, October 15, 2008

LOGINPROPERTY - information about login policy settings
LOGINPROPERTY (information about login policy settings)
 
LOGINPROPERTY function returns information about the password policy settings of a SQL Server login.
The names of the properties are not case sensitive.
NULL will be returnd if the login is not a valid SQL Server login.
< ...
Comments (0) More...
Aleksandar Tosic's Blog T-SQL By Alex on Wednesday, October 15, 2008

DotNetNuke® Claims Visual Studio Magazine Award
DotNetNuke® Corporation, producers of the highly acclaimed open source web application framework for the Microsoft platform, today announced that the product has been honored with the 2007 Editors Choice Award from Visual Studio Magazine as part of their annual Readers’ Choice Awards. The full list of winners, which appears in the June 2007 issue, is chosen by Visual Studio Magazine’s readers and honors excellent software in 22 development categories. The Editors Choice Award is a special designation given to products which show “special merit or innovation.”
More...
Stevan Tosic By host on 10/15/2008 10:40 AM

How to empty a database file - Emptying a file

Emptying a file

The following example demonstrates the procedure for emptying a file so that it can be removed from the database. For the purposes of this example, a data file is first created and it is assumed that the file contains data.

http://msdn2.microsoft.com/en-us/library/ms189493.aspx

USE AdventureWorks;
GO
-- Create a data file and assume it contains data.
ALTER DATABASE AdventureWorks
ADD FILE (
    NAME = Test1data,
    FILENAME = 'C:\t1data.ndf',
    SIZE = 5MB
    );
GO
-- Empty the data file.
DBCC SHRINKFILE ('Test1data', EMPTYFILE);
GO
-- Remove the data file from the database.
ALTER DATABASE AdventureWorks
REMOVE FILE Test1data;
GO

Comments (0)
Aleksandar Tosic's Blog Database Files By Aleksandar Tosic on Wednesday, October 15, 2008

MSQL_XP - wait type on sys.dm_os_wait_stats

MSQL_XP is the  wait type that occurs when a task is executing an extended stored procedure - XP. SQL Server does not have control over an XP even though it is executing within the SQL Server process. Investigation of these waits requires investigating the execution of the extended stored procedure code—the vendor may have provided diagnostic tools for the XP. If such tools are not available and the source code of the XP is not available and the documentation does not provide other troubleshooting information, contacting the vendor may be the only option.

 

Comments (0) More...
Aleksandar Tosic's Blog Blocking By Aleksandar Tosic on Wednesday, October 15, 2008

Msg 7411 - Server "ServerName" is not configured for DATA ACCESS.

To alow darta access through linked server using OPENQUERY we need to set set linked server "DATA ACCESS" option to true:

EXEC sp_serveroption 'YourServer', 'DATA ACCESS', TRUE

Use this option when you get following error message:

Msg 7411, Level 16, State 1, Line 1

Server 'MYSERVER' is not configured for DATA ACCESS.

Comments (1)
Aleksandar Tosic's Blog Configuration By Aleksandar Tosic on Wednesday, October 15, 2008

Upgrading Editions of Reporting Services

Upgrading from SQL Server 2000

SQL Server 2005                         SQL Server 2005
Evaluation                                     Express, Workgroup, Standard, Developer, Enterprise
Express                                         Workgroup, Standard, Developer, Enterprise
Workgroup                                    Standard, Developer, Enterprise
Standard   &nbs ...

Comments (0) More...
Aleksandar Tosic's Blog Reporting Services 2005 By Alex on Wednesday, October 15, 2008

Attach Database using only mdf file where ldf is missing
CREATE DATABASE PagingSample
ON PRIMARY
(FILENAME= 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\PagingSample.mdf')
FOR ATTACH
ATTACH_REBUILD_LOG
Comments (0)
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

Using Blocked Process Report event class in SQL Server Profiler 2005.

sp_configure 'show advanced options', 1 ;
GO
RECONFIGURE ;
GO
sp_configure 'blocked process threshold', 10 ;
GO
RECONFIGURE ;
GO

Create a new trace in Profiler and select the "Blocked Process Report" event listeds under the "Errors and Warnings" event category.

After this setup, you should see all blockings taking longer than 10 seconds using this trace.

Comments (0)
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

MSDN Product Licensing
MSDN Product Licensing
Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

@@IDENTITY and SCOPE_IDENTITY()
 
@@IDENTITY and SCOPE_IDENTITY() will return the last inserted identity value in the current session but in different scenarios they can each return different values.
While both @@IDENTITY and SCOPE_IDENTITY return the last identity value generated in any table in the current session, SCOPE_IDENTITY() will return the value only within the current scope (a scope is a stored procedure, trigger, function, or batch) while @@IDENTITY is not limited to a specific scope.
 
For example, nested stored procedures or triggers are part of the current session, but not part of the current scope. A scope is limited to the stored procedure or function that is explicitly invoked. This is how the @@IDENTITY and SCOPE_IDENTITY() can return different value when executing same stored procedure.
Comments (0)
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

SQL Server 2005 Service Pack 1

To  download SQL Server 2005 Service Pack 1 visit: http://www.microsoft.com/downloads/details.aspx?familyid=cb6c71ea-d649-47ff-9176-e7cac58fd4bc&displaylang=en

Comments (0)
Aleksandar Tosic's Blog Service Packs By Aleksandar Tosic on Wednesday, October 15, 2008

SQL Server Service Pack 2

Microsoft released Service Pack 2 for SQL Server 2005. You can download the SP2 here.

Some of the changes are

·                                trigger on logon event

Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

SQL Server 2005 Service Pack 2

To  download SQL Server 2005 Service Pack 2 visit: http://www.microsoft.com/downloads/details.aspx?FamilyId=d07219b2-1e23-49c8-8f0c-63fa18f26d3a&DisplayLang=en

Comments (0)
Aleksandar Tosic's Blog Service Packs By Aleksandar Tosic on Wednesday, October 15, 2008

Microsoft SQL Server 2005 Downloads

 

To download SQL Server 2005 service packs, tools, trial software visit: http://technet.microsoft.com/en-us/sqlserver/bb331754.aspx

Comments (0)
Aleksandar Tosic's Blog SQL Server 2005 Downloads By Aleksandar Tosic on Wednesday, October 15, 2008

DBCC LOGINFO ('DATABASENAME')

Use an undocumented DBCC command DBCC LOGINFO to to see if VLF's contain active transactions. 

DBCC LOGINFO('DATABASENAME')

 

Click below for more details:
Comments (0)
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

SQL Server 2005 Report Packs
SQL Server 2005 Report Packs
Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

Using textcopy.exe utility to impoty images

Importing Images with textcopy utility.

 

Use textcopy.exe utility. Check this: http://www.databasejournal.com/features/mssql/article.php/1443521 or http://www.windowsitlibrary.com/Content/77/03/4.html or http://www.mssqlcity.com/Articles/KnowHow/Textcopy.htm

Comments (0)
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

proxy account information - xp_sqlagent_proxy_account
proxy account information - xp_sqlagent_proxy_account

check this

http://msdn2.microsoft.com/en-us/library/aa260700(SQL.80).aspx

to find out if any proxy account is used or not and how toset one.

and this one:

http://msdn2.microsoft.com/en-us/library/aa260289(SQL.80).aspx

to find out when and how to use a proxy account.

Permissions
Execute permissions default to the public role in the msdb database. A user who can execute this procedure and is a member of the sysadmin fixed role can start any job. A user who is not a member of the sysadmin role can use sp_start_job to start only the jobs he/she owns.

When sp_start_job is invoked by a user who is a member of the sysadmin fixed server role, sp_start_job will be executed under the security context in which the SQL Server service is running. When the user is not a member of the sysadmin fixed server role, sp_start_job will impersonate the SQL Server Agent proxy account, which is specified using xp_sqlagent_proxy_account. If the proxy account is not available, sp_start_job will fail. This is only true for Microsoft® Windows NT® 4.0 and Windows 2000. On Windows 9.x, there is no impersonation and sp_start_job is always executed under the security context of the Windows 9.x user who started SQL Server.


AND

Sets or retrieves the proxy account information used by SQL Server Agent and the xp_cmdshell extended stored procedure when executing jobs or commands for users who are not members of the sysadmin fixed server role. The proxy account is a Microsoft® Windows® account in whose security context the jobs or command prompt commands are run.



Stevan Tosic By host on 10/15/2008 10:40 AM

DB_CHAINING and TRUSTWORTHY

ALTER DATABASE MSDB
SET DB_CHAINING ON
GO

ALTER DATABASE MSDB
SET TRUSTWORTHY ON
Stevan Tosic By host on 10/15/2008 10:40 AM

Encrypted HTML Decoding Tools
Encrypted HTML Decoding Tools
Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

Create a foreign key on an existing table in SQL Server
Use code below to create a foreign key on an existing table in SQL Server ALTER TABLE Table1 ADD FOREIGN KEY (Column_Name) REFERENCES Table2(Column_Name)
Comments (0) More...
Aleksandar Tosic's Blog T-SQL By Alex on Wednesday, October 15, 2008

Automatic Reindexing and Microsoft SQL Server 2000 Index Defragmentation Best Practices

Two great links for Microsoft SQL Server 2000 Index Defragmentation Best Practices and Automatic Reindexing.

These links provides information that you can use to determine whether you should defragment indexes to benefit the workload performance in your production environment. And how...

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx

http://www.sqlmag.com/Articles/ArticleID/43783/pg/2/2.html

 

Stevan Tosic By host on 10/15/2008 10:40 AM

test
test
Comments (0) More...
Aleksandar Tosic's Blog Blocking By Aleksandar Tosic on Wednesday, October 15, 2008

Online Index Operations - SQL Server 2005
The online index feature provides a powerful way to perform maintenance operations such as rebuilding or creating indexes in a production system without sacrificing DML concurrency.

This feature allows concurrent modifications (updates, deletes, and inserts) to the underlying table or clustered index data and any associated indexes during index data definition language (DDL) execution. For example, while a clustered index is being rebuilt, you can continue to make updates to the underlying data and perform queries against the data.

Users are not blocked from querying and updating the underlying table during the index operation. Check these link for more details: 

Comments (0) More...
Aleksandar Tosic's Blog Performance By Aleksandar Tosic on Wednesday, October 15, 2008

SQL Server 2005 Catalog view

In SQL Server 2005, the system tables are gone. The system tables from previous versions of SQL Server are now implemented as a series of views called catalogue views and all of these catalogue views can be found in the sys schema.

select * from sys.all_views WHERE is_ms_shipped = 1

http://searchsqlserver.techtarget.com/tip/1,289483,sid87_gci1089808,00.html

 

Comments (0)
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

Selecting random pages using tabid in DotNetNuke based on tabname similarity

declare @tabid int
declare @tabname nvarchar(100)
set @tabid = 7
--select * from tabs where tabid = @tabid
select @tabname = tabname from tabs where tabid = @tabid
--select * from tabs where IsVisible = 1 and ParentID is null
select top 10 DIFFERENCE(@tabname,tabname),@tabname,tabname from tabs where IsVisible = 1 and ParentID is null order by DIFFERENCE(@tabname,tabname) desc

This code is used to list similar tabnames (pages) when tabid is provided.

Comments (0)
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

Monitor Microsoft SQL Server for higher performance and availability with WildMetrix

Great SQL Server Monitoring Tool.

WildMetrix says:

"Benefits of Monitoring Microsoft SQL Server with WildMetrix

Helps administrators detect problems in their SQL Server architecture
Quickly diagnose exactly where and what the problems are
Resolves the problems from a single easy-to-use interface
Gain understanding of entire SQL Server system inside and out"


Product

http://www.ascendview.com/wildmetrix/sol_mssqlserver.asp

Demo

http://www.ascendview.com/resources/request.asp?Activity=Eval

Stevan Tosic By host on 10/15/2008 10:40 AM

Use SQL Server 2005 to get information from Active Directory about users, groups etc.
Use this script to  list Active Direct users from SQL Server 2005. 'ADSI', 'droplogins' 
 
 sp_dropserver
GO

EXEC master.dbo.sp_addlinkedserver @server = N'ADSI', @srvproduct=N&l ...

Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

Find most frequently executed queries in SQL Server 2005 - sys.dm_exec_query_stats

Use dm_exec_query_stats to find data for all statements in the cache: number of times the query has been executed, the longest query to execute.

Use these tow objects:

sys.dm_exec_query_stats
sys.dm_exec_sql_text

 Run this query to find most frequently executed queries in SQL Server 2005

select* from sys.dm_exec_query_stats as across apply sys.dm_exec_sql_text(a.sql_handle) as b order by execution_count desct
Run DBCC FREEPROCCACHE to to clear the procedure cache before start monitoring.

Stevan Tosic By host on 10/15/2008 10:40 AM

Formatting data in Reporting Services 2005 when creting report

 

FormatDateTime function i a VBScript function the formats date or time.

Example:

= FormatDateTime(Fields!PublicationDate.Value,2)

Formats

vbGeneralDate  0  Display a date in format mm/dd/yy. If the date parameter is Now(), it will also return the time, after the date
vbLongDate  1  Display a date using the long date format: weekday, month day, year
vbShortDate  2  Display a date using the short date format: like the default (mm/dd/yy)
vbLongTime  3  Display a time using the time format: hh:mm:ss PM/AM
vbShortTime  4  Display a time using the 24-hour format: hh:mm
Comments (0)
Aleksandar Tosic's Blog Reporting Services 2005 By Alex on Wednesday, October 15, 2008

SQL Server Injection - SQL Server Security Hacks - Best SQL Injection Tools

SQL Server Injection

Great article and great tools:
http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1159434,00.html#

SQL Server Security Hacks
Top 15 free SQL Injection Scanners
http://www.security-hacks.com/2007/05/18/top-15-free-sql-injection-scanners


HP WebInspect performs web application security testing
https://h10078.www1.hp.com/cda/hpms/display/main/hpms_content.jsp?zn=bto&cp=1-11-201-200%5e9570_4000_100__


Wikto: Web Server Assessment Tool
http://www.sensepost.com/research/wikto/

This is a modified version of 'bsqlbfv1.2-th.pl'. This perl script allows extraction of data from Blind SQL Injections. It accepts custom SQL queries as a command line parameter and it works for both integer and string based injections.

Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

Capitalize the first letter of every word in a text string or column - SQL Server
capitalizes the first letter of every word in a given text string
Comments (0) More...
Aleksandar Tosic's Blog By Aleksandar Tosic on Wednesday, October 15, 2008

 
Announcements Minimize
SQL Server Service Pack Versions - Thursday, October 30, 2008
Version @@VERSION MsDtsSrvr.exe File Version Registry Version Registry Patch Level
Release to Manufacturing 9.00.1399.00 9.0.1399.0 9.0.1399.06 9.0.1399.06
Service Pack 1 9.00.2047.00 9.0.2047.0 9.1.2047.00 9.1.2047.00
Post SP1 Cumulative Hotfix 9.0.2153.00 9.0.2153.0 9.1.2047.00 9.1.2153
Service Pack 2 CTP 9.00.3027.00 9.0.3027.0 9.2.3027.00 9.2.3027.00
Service Pack 2 9.00.3042.00 9.0.3042.0 9.2.3042.00 9.2.3042
Service Pack 2 Rollup 3 9.00.3186.0 9.00.3186.00 9.2.3042.00 9.2.3186
 

Print