Posts Tagged ‘microsoft’

How to: Get the name of the running SQL-server instance

Here’s a script to retrieve the name of the currently running SQL Server instance: SELECT @@SERVERNAME AS ‘ServerName’ Resultset: ServerName ————————— DEV-SQL (1 row(s) affected)

More »

SQL-server: Get current database name

It can sometimes be handy to know in which database you are working. To get the name of the current database you can use a simple script: SELECT DB_NAME() AS DataBaseName Resultset: DatabaseName ———————— NorthWind (1 row(s) affected)

More »

Am I running as a 32 or 64-bit application?

Here’s an easy way to determine if a .NET application is running as either 32 or 64-bit  application. VB Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)   If IntPtr.Size = 8 Then     Response.Write("64-bit")   ElseIf IntPtr.Size = 4 Then     Response.Write("32-bit")   End If End Sub C# protected void [...]

More »

Error message 401.2.: Unauthorized: Logon failed due to server configuration. (IIS7)

After installing Windows 7 my ASP.NET application displayed an Access is deniederror. The complete error message was: Error message 401.2.: Unauthorized: Logon failed due to server configuration.  Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.  Contact the Web [...]

More »

Select column names from a Microsoft SQL-Server table

I’ve posted a snippet before that allows you to select a list of tables (or views, stored procedures, etc) from a SQL-Server database. It would be only logical to also have a snippet that allows you to select the columns in the table you’re interested in. The following piece of SQL code does just that. [...]

More »

MultipleActiveResultSets (MARS), SQL server 2000 and LINQ

Using the MultipleActiveResultSets setting in a connection string allows one to have multiple datareaders open on the same connection, at the same time. This setting was introduced with SQL server 2005. Setting it with SQL server 2000 does not have any effect, or so I thought.

More »

How to: Change ‘sa’ password on SQL server 2008

If you happen to forget your SQL Server password for ‘sa’ account, then here’s a simple query to help you reset it: ALTER LOGIN [sa] WITH DEFAULT_DATABASE=[master] GO USE [master] GO ALTER LOGIN [sa] WITH PASSWORD=N’MyNewPassword’ MUST_CHANGE GO In Case you remember your Old Password and want to change the ‘sa’ password, use this query: [...]

More »

SQL Server 2005 Standard Edition 64-bit does not support ‘lock pages in memory’

In a production environment we have a 64-bit SQL Server Std edition running on Windows Server 2003 x64 Enterprise. The box used to contain 16GB of RAM, but to improve performance we upgraded to 64GB. As suggested by Books Online, SQL Server needs permission to ‘lock pages in memory’ to take advantage of the available [...]

More »

Select all User Tables in a MS-SQL server database

Sql statement to enumerate all user tables in a MS-SQL instance. SELECT a.[Name] as FunctionName FROM sysobjects a WHERE a.xtype = ‘U’ Meaning of sysobject.xtype values D : ? F : foreign keys FN : user defined functions P : stored procedures PK : primary keys S : system tables TR : triggers U : [...]

More »