How to test for multiple row actions in a SQL Server trigger?

My kindergarten SQL Server taught me that a trigger may be fired with multiple rows in the inserted and deleted pseudo tables. I mostly write my trigger code with this in mind, often resulting in some cursor based cludge. Now I’m really only able to test them firing for a single row at a time. […]

Force T-SQL query to be case sensitive in MS

I have a table that originates in an old legacy system that was case senstive, in particular a status column where ‘s’ = ‘Schedule import’ and ‘S’ = ‘Schedule management’. This table eventually makes its way into a SQL Server 2000 database which I can query against. My query is relatively simple just going for […]

return items that all records related to that items have specific conditions

please consider this scenario: I have a table like this: ID City Status ————————————– 1 1 1 2 1 1 3 1 1 4 2 1 5 2 0 6 3 1 7 3 1 8 3 1 9 3 1 10 4 3 11 4 1 12 4 0 I want to return Citis […]

There is insufficient system memory in resource pool 'default' to run this query

I’m getting this error: There is insufficient system memory in resource pool ‘default’ to run this query. I’m just running 100,000 simple insert statements as shown below. I got the error approx on the 85,000th insert. This is a demo for a class I’m taking… use sampleautogrow INSERT INTO SampleData VALUES (‘fazgypvlhl2svnh1t5di’,’8l8hzn95y5v20nlmoyzpq17v68chfjh9tbj496t4′,1) INSERT INTO SampleData […]

How do I configure a SQL Server datasource in JBoss to connect using a specific Active Directory user?

JBoss runs as Active Directory user ABC\appuser. I want to connect to a MS SQL Server 8.0 database as AD user ABC\dbuser. Using parameter integratedSecurity=true, unless I specify user=ABC\dbuser;password=dbpass on the connection url, the system will try to connect as the service AD user, ABC\appuser. Per this question, I have confirmed that by using the […]

SQL – Where criteria to find names between A-F

Simple question: I need a solution so that I can find, lets say names, between A-F, INCLUDING all names that start with F. If you use BETWEEN or A >= value <= F you find out that it stops at F. So I am posting this for suggestions. NOTE: User will see 2 textboxes that […]

ValidateExternalMetadata property, what exactly does this do?

I have a package which reads data from a table and based on a column value stores the records in two other tables. Package uses Transaction required property. It was running smooth until recently when I created a non-clustered index on source table to improve performance. The package denies to proceed execution after showing the […]

Convert Datetime to Unix timestamp

In Microsoft SQL Server 2012 or above, is it possible to convert a datetime value to Unix time stamp in a single select statement? If so, how can it be done?

Finding approximately duplicate database records using T-SQL?

Hey all. I have a MSSQL 2008 database with a fair number of rows. As of now, before new rows are inserted into the table, the stored procedure checks to see if that record already exists in the database (by checking a column labeled Title). This check is exact, and if the to-be-inserted record is […]

VBA clear just pivot table cache, but leaving pivot table structure

How can I clear pivot table cache with VBA, but not destroy pivot table structure? My pivot table is connected to external data source. The SQL source determines which user should see which portion of the data. The source populates the table as the table is refreshed. I want to save the Excel file and […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.