Tag: sql-server-2012

Purge job optimization

SQL Server 2008 R2 Enterprise I have a database with 3 tables that I am keeping a retention time of 15 days. This is a logging database that is very active and about 500 GB in size and eats about 30GB a day unless purged. I can’t seem to get caught up on one of […]

How can i get the days between results dates for each seperate pat_id?

I’m looking to get the days between result dates for each patient: only looking at result dates where the result value is <90.00 ;WITH patient_results AS ( SELECT * FROM (VALUES (1, ‘EA11AEE3-1D90-4602-9A37-0000007E2293’, ‘85.10’ ,’2015-12-11′), (1, ’27BCD3E4-2381-4139-B420-0000025B4113′, ‘91.50’ ,’2016-01-05′), (1, ‘D8969360-45D6-487B-AF94-0000035F78B0’, ‘81.00’ ,’2016-07-21′), (5, ‘446E6413-442A-452A-BCF4-000006AA9896’, ‘58.00’ ,’2014-07-01′), (5, ‘00305129-BC14-4A12-8368-00000AC04A9B’, ‘53.00’ ,’2014-12-13′), (5, ’96A67E53-2D6C-430B-A01F-00000AE4C37B’, ‘42.80’ ,’2015-02-01′), […]

List of primary key components

I am making a list from a database where I want to show the number of columns that make up the primary key in each particular table in SQL Server. For example, if Table A has a single column as primary key, Table B has a compound key of 3 parts, and Table C has […]

Add values of a column and display added result in new table

The table with the data that I have In the above table I have the columns : weekNumber , weeklyHours , points_Rewarded. There are four employees : a,b,c,d I have the values for week1,week2,week3, and so on ( I can have data for many more weeks also such as week4,week5, etc) I want to write […]

Using Full-Text indexing to crawl binary blobs

If i store binary files (e.g. doc, html, xml, xps, docx, pdf) inside a varbinary(max) column in SQL Server, how can i use Full-Text indexing to crawl the binary files? Imagine i create a table to store binary files: CREATE TABLE Documents ( DocumentID int IDENTITY, Filename nvarchar(32000), Data varbinary(max), ) How can i leverage […]

I am trying to write a query to track use of terminals. I want to show all terminals that have not had activity for 1 year

I am trying to write a query to track the use of PC terminals. I want to show all PC terminals that have not had activity for 1 year. This is the query that I am trying to use and it returns 0 results even though I know I have terminals that have not been […]

LDAP connection in Clustered instance sql job returns null results

I wrote the following PowerShell script. It works in jobs on my non-clustered SQL Servers (2014 version). It works on my clustered server when I run it manually out of PowerShell (2012 version). However, it returns null results for the users in the LDAP query when I run it as part of a SQL Agent […]

How to get a single column's value from a stored procedure call within a stored procedure?

I have the following procedure: SP_Validate_User_Main ( @UserName VARCHAR(20), @Password VARCHAR(20), @From VARCHAR(10), @IP VARCHAR(15) ) — does a bunch of stuff, then the following line is the last to execute EXECUTE SP_Validate_User @aUserName = @UserName, @aPassword = @Password Depending on the validity of the data passed to SP_Validate_User, 1 of 2 statements will then […]

Select 1 record out of many for time period

I am trying to select records where i only have 1 record if there are overlapping dates. I have looked around and found questions close but could not get them to work for what problem i have. If you could help me out i would greatly appreciate it. Problem is a member can have many […]

SQL Server Error executing SQL stored procedure in ASP classic Error

Please see the SQL server error messages I am getting when executing a SQL Server stored procedure from ASP classic. I am using two session variables as parameters for the stored procedure. I had no issues with this, until just recently I started getting the following error, the errors are different between production and test […]

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