Skip to content

The Dummy Programmer

Stories of daily programming

  • Home
  • My other dummy projects
  • Games
    • Space Y: An Asteroids clone
  • Services
    • What’s my user agent
    • What’s my IP address
  • About
  • Toggle search form

Category: Sql Server

Sql Server: apply an aggregate function to fields values in a row

Did you ever need to apply an aggregate function to fields values in a row? It happened to me just few days ago… I will try to explain better what I mean… Suppose you have a Sql Server table created with the following script: CREATE TABLE ROW_AGGREGATE_EXAMPLE ( ID INT IDENTITY(1, 1) PRIMARY KEY CLUSTERED,…

Read More “Sql Server: apply an aggregate function to fields values in a row” »

Sql Server

How to know who is blocking a query in Sql Server

It’s been a while since we last heard… The Dummy Programmer was really really busy and couldn’t write any post. But now I’m back to talk about a problem I came across. One of my applications in the production environment seemed to be stuck doing a series of database queries. My suspicion is that some other…

Read More “How to know who is blocking a query in Sql Server” »

Sql Server

Improving SQL Server cursor performance

Hi everyone! Today I want to talk about a performance problem I had a few days ago using a SQL Server cursor. Imagine using a cursor in the following classic way: DECLARE @ID INT DECLARE @ITEM_CODE VARCHAR(50) DECLARE MY_CURSOR CURSOR FOR SELECT ID, ITEM_CODE FROM MY_TABLE T LEFT JOIN A_TABLE T1 ON T.ID = T1.ID LEFT…

Read More “Improving SQL Server cursor performance” »

Sql Server

Delete all rows from all tables in a Sql Server database

Delete all rows from all tables in a Sql Server database may not be an easy task. This because in a relational database you have foreign keys between tables, and to empty all tables you have to write delete statements in the correct order to avoid foreign key violations. I know that there are scripts…

Read More “Delete all rows from all tables in a Sql Server database” »

Sql Server

Search a string in stored procedures, functions and views in a SQL Server database

If you want to search a string in stored procedures, functions and views, maybe you can use some special tools. But, for instance, suppose that you can only use SQL Server Management Studio. Is there a way to do this? Yes…. You could use the following query: SELECT DISTINCT OBJECT_NAME(id) AS [OBJECT_NAME] FROM sys.syscomments WHERE…

Read More “Search a string in stored procedures, functions and views in a SQL Server database” »

Sql Server

Load a huge amount of data in a Sql Server table

Last week I had to load a huge amount of data, about 500,000 rows, in a Sql Server table to make some data processing. Using the “Sql Server Import and Export Data” tool this was an easy job. After processing data in my own Sql Server, I had to reload the data to another Sql…

Read More “Load a huge amount of data in a Sql Server table” »

BCP

The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine

I was trying to load the content of an xlsx file into a Sql Server database using the “Sql Server import and export wizard” provided by Sql Server Management Studio, and I got the following error “The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine”. The error persisted even after the installation of the…

Read More “The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine” »

Excel

SQL Server LEN function return 0 passing a string with one space

Try to answer this riddle: What is the result of this SQL Server query: PRINT LEN(‘ ‘) I would answer 1, since I passed a string with one space…. but it’s the wrong answer. In this case the LEN function returns 0! Why this behavior? If you check the Sql Server documentation at https://docs.microsoft.com/en-us/sql/t-sql/functions/len-transact-sql?view=sql-server-2017 this…

Read More “SQL Server LEN function return 0 passing a string with one space” »

Sql Server

Sql Server error using a database with a CLR assembly

Few days ago, I got a Sql Server error using a database with a CLR assembly installed. Running my application I got the following error: “An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted…

Read More “Sql Server error using a database with a CLR assembly” »

CLR

Reset Sql Server cache

Sometimes is useful to check how a certain query or a stored procedure behaves without cached data, so in this post I will show you how to reset SQL Server cache. To do the job, simply run these statements from SQL Management Studio: CHECKPOINT GO DBCC DROPCLEANBUFFERS GO DBCC FREEPROCCACHE GO

Sql Server

Posts pagination

Previous 1 2

Copyright © 2024 The Dummy Programmer | Privacy Policy | Terms of use |

Powered by PressBook Masonry Dark

Manage Cookie Consent
This site doesn’t collect user personal data and doesn’t install profiling or analytical cookies, either its own or from third parties. Read our privacy policy for more info.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}