All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag like sql-server-2016 if that is relevant to the question.

learn more… | top users | synonyms (2)

2
votes
3answers
114 views

String Function to Get Left 1000, But Only To Last Period or Carriage Return

I have blocks of text, anywhere between 500 and 2000 characters long. What I need to be able to do is take a maximum of 1000 characters from the description but only to the last full stop or ...
0
votes
0answers
119 views

How to import data from Sqlite into SQL Server 2012

I need to import data from sqlite into SQL Server so we can include it in our data warehouse. Based on previous system volume. Id expect there to be 50-100,000 rows after a couple of years. For ...
1
vote
1answer
23 views

What is the logic of a query when using like with and/or

I have a table that contains subtitles ranging from subtitles_a to subtitles_z. I'm not sure why this query isn't working? select * from subtitles where field_name like '%subtitle_u%' or field_name ...
0
votes
1answer
75 views

About employee who come out at night

I have a table like this: EmployeeId Checktime 1 2015-10-14 07:51:25.000 1 2015-10-14 18:56:47.000 1 2015-10-15 00:04:04.000 I want to get the minimum ...
13
votes
0answers
202 views

Service broker was backed up, now receiving, but doesn't seem to be processing

Having a problem with Event Notifications. On the machine/drive/database that the messages are sent to (receiver), the drive filled up when nobody was looking, so it's been backed up all day. Now ...
1
vote
1answer
130 views

How to get SQL Server CPU and Memory read and write usage within two weeks?

Is there any a quick way or quick script on how to get the CPU and Memory usage within a time range (at least two weeks)? I did my research earlier and it seems that the procedures available seems ...
1
vote
1answer
48 views

How to re-include excluded folder in SSDT-BI / Visual Studio 2013 database project?

I've selected "Excluded from project" on a folder with tables (database was imported first into project). Now I would like to re-include this folder into the project. In the "Add Existing Item" option ...
0
votes
1answer
22 views

Foreign key not able to get one to many working

I want to have a one to many relation with player points but I need it in such a way that entity framework sees it as a collection so i can add to it. I mean that one player can have multiple points ...
2
votes
1answer
2k views

How do I connect to localDB from SQL Server 2014 Express

I downloaded both the LocalDB and Management Studio for MS SQL Server 2014 Express so that I can practice on my local machine. However, when I open Management Studio and try to browse to localDB to ...
1
vote
0answers
46 views

SSIS package with changes to Excel file

I have an SSIS package that loads up an Excel file on daily bases; from time to time the file changes. It can have additional columns in the Excel worksheets. How can I know if the Excel file has ...
0
votes
1answer
108 views

User databases inaccessible after physical restart

We have an unusual error happening on the SQL Server. After restarting the physical server where the SQL Server instance is installed, the user databases are not accessible. System databases are ...
0
votes
1answer
91 views

What is the cause of high index fragmentation in SQL server?

We have an application which is using a SQL Server database. As the application is in use for many years, its database is of huge size, resulting in slowness of application. It was noticed that the ...
2
votes
1answer
68 views

Is my table is stored as heap or b-tree?

I have a SQL Server 2005 database. It’s .MDF & .LDF can be downloaded at https://www.dropbox.com/s/uj2mw410jm2m078/MyDB.rar?dl=0 Now I want to know whether two table are stored as heap or b-tree(...
0
votes
2answers
40 views

How can I handle delayed records a month or older on a table clustered on time?

I have a two part question really for anyone working with data warehousing where they have large fact tables. Question 1 Lets say you have a table that has 500 million or more records in it that is ...
1
vote
2answers
125 views

Parameters in Activity Monitor

To view "recent expensive queries" I use Activity Monitor. Some of the queries there are with parameters. Is there a way to know the values?
0
votes
0answers
39 views

Perform Join After Filter

I am developing a laboratory database query which compares test results (testResults) to specification conditions (specCond). I cannot get SQL Server to retrieve the results efficiently. Schema: ...
4
votes
1answer
128 views

Minimum distance of a location; one table of points compared to a set of points SQL 2012

I am trying to find the quickest way to find the minimum distance of one point to a table of points. The only caveat is that the table of the points I'm trying to find the minimum distance of is 150K ...
2
votes
1answer
63 views

SQL Server 2012 Log File Best practice

We have a 2012 SQL Server and I am looking into how it is being backed up currently. We do have a shadow copy that runs hourly. We also have a nightly full backup that is taken. DB runs in FULL mode. ...
0
votes
1answer
41 views

How to pivot this unpivot?

This is the pivot I made: SELECT * FROM ( SELECT *-- codigo,ID,Grupo,convert(int,CodOpcao) as CodOpcao FROM ( SELECT * FROM ( SELECT 39 as codigo , ...
2
votes
2answers
374 views

Should I shrink this SQL Server data file?

I have read many articles describing how shrinking data files causes terrible things to happen floods, famine, fragmentation, and general mayhem. Here is the cliff notes of my situation: SSAS ...
1
vote
1answer
106 views

SQL Server database has corruption, but displays no errors

We have an extensive database of tables. I moved over a table from our dev db to our production db using a program called SQL Compare. I just copy paste the SQL it produces into Management Studio and ...
2
votes
0answers
60 views

SQL Server 2014 Log shipping - column error

I'm trying to set up log shipping between two instances of SQL Server 2014 Dev edition. Backup and copy jobs work flawless, but the restore one keep failing with the following error: An error ...
2
votes
3answers
120 views

SQL Server Pagination using CTE

I have to apply paging on query as per requirement i need two extra columns other than query result 1. Total Records 2. Total Pages but i am trying to confirm that this the right way to retrieve ...
0
votes
1answer
31 views

SQL Server - Check for opened Activity Monitor

I'm looking for a way to send an alert when a DBA tool is connected for "too long" on a SQL Server Production database. For most of the tools I listed out, I can find the program name with the ...
0
votes
1answer
33 views

SQL query help: Calculating days between observations

I'm extremely new to SQL, in fact, I just really started playing around with it. So I'm not exactly sure how to search for appropriate terms related to the question I have. I'll do my best. CONTEXT:...
0
votes
1answer
113 views

Best practice design schema for implementing form approval tracking?

I'm in the middle of creating an ASP.NET MVC 5 web app using windows SQL server as my DB setup. The app has a very simple purpose: Allow a user to submit a form to be signed by multiple people, ...
0
votes
1answer
69 views

Get SQL server instance installation date [duplicate]

I would like to know the date when the sql server installed on the system. I did try to look in %programfiles%\Microsoft SQL Server\100\Setup Bootstrap\Log\ directory but there are so many files and ...
1
vote
1answer
39 views

Default Backup to be Copy-Only

We have a 3rd party Payroll application which uses a SQL database on our server. On the database server we have weekly full backups, nightly differential and regular log backups. These are kept for a ...
2
votes
1answer
52 views

What is the date mentioned in @@version SQL Server

I wanted to know what the date that is result of select @@vesion in SQL server refers to. Microsoft SQL Server 2012 - 11.0.5058.0 (X64) May 14 2014 18:34:29 Copyright (c) Microsoft Corporation ...
2
votes
0answers
2k views

How to resolve error “object reference not set to an instance of an object” in SQL Server 2014

I installed SQL Server 2014 Management Studio on my system few months age. It was working fine until yesterday. But today, when I started SSMS and clicked on "New Query" option, I got an error ...
-1
votes
1answer
71 views

What is the best source for deep learning about table partitioning? [closed]

I know some of the basics of table partitioning, but I haven't used it for an operational database yet, as I went studying more about the topic, I found some information that is written for SQL server ...
2
votes
2answers
193 views

How long is the output of EncryptByPassPhrase(), relative to the input?

I'm starting an encryption project, using EncryptByPassPhrase(), mostly on VARCHAR values. Naturally, the encrypted values are longer than the originals. Is there a formula I can use to calculate ...
2
votes
1answer
49 views

Putting SQL Server databases into individual folders

We have a Dev server where we are trying out some automated partitioning scripts. The folder is getting quite large in terms of number of files. Is it possible to automatically have SQL Server use ...
0
votes
1answer
37 views

How to Override a column in table.*

select (column1+column2) AS column1, table1.* from table1 both column1 and column2 are columns in table1. Is there anyway that when I run the query I can get only the new column1 is shown and the ...
-1
votes
2answers
27 views

how do i take the end value of a colum, convert to date and insert into a new column

I have a column [week] in a table [wkd] with a value of 11/08 - 11/14. They are strings with 2 date ranges. (nov 8 - nov 14). what I need to do is get 11/14 into a new date column [weekending] so ...
1
vote
3answers
287 views

Perform regex search queries of a text column in table of 100+ million using regex

I apologize if this is a newbie question but I'm feeling overwhelmed. I have 100+ million 2-grams(string with two words), 100+ million trigrams, 100+ 4-grams. I was thinking of separating 2-grams ...
13
votes
1answer
1k views

Running SSIS package from SQL Agent job owned by a non-sysadmin domain user

I have two SSIS packages that run scheduled overnight (via SQL Server Agent) as part of a larger SSIS deployment, without any issues. Everything is using Windows authentication, and the scheduled job ...
0
votes
0answers
43 views

“begin transaction” yields error

The entirety of my code is: BEGIN TRAN --SACTION SELECT 1 COMMIT --TRAN with any combination of tran, transaction or neither it always returns error: Incorrect syntax near the keyword 'BEGIN'. I'...
0
votes
0answers
28 views

Attach replicated .MDF file with/without log after OS reinstalled

I have SQL Server 2014 DataCenter RTM Version on Windows 2012 Standard Edition for about 2 months and had migrated a database from SQL Server 2008 R2. The database had transactional replication was ...
1
vote
1answer
41 views

Delete query does not appear to open space on the SQL Server

Our SQL Server (version 2012) is housed on a cloud server, for which we pay whenever we need additional space. We determined that we could delete some of the data to prevent the need for continually ...
2
votes
1answer
71 views

looking for a cleaner way to select from multiple tables

I'm currently using this code to select from 2 tables using a stored procedure. DECLARE @now as varchar(26) set @now = CONVERT(VARCHAR(26), SYSDATETIME(), 9) --Select 'SMD_' + replace(convert(...
4
votes
2answers
226 views

How to update only part of a field

A user entered a batch of records with the wrong suffix in the record name - FY15-Q2 instead of FY16-Q1. So, the records are something like: -LAG-FY15-Q2 -AN-FY15-Q2 -OY-FY15-Q2 -RV-FY15-Q2 etc ...
0
votes
1answer
37 views

Best tool/approach to report on table contents over time

I've got a table in SQL Server full of data that is a working DB of data collection reports. This table only stores the current state (meaning it doesn't keep historic anything). There are a few key ...
8
votes
1answer
16k views

Planned release date for the next version of SQL Server [closed]

Has Microsoft published a roadmap for the next version, identifying a planned release date? If not, how long do you think before the next version becomes production ready?
0
votes
0answers
24 views

Creating Common Fields across Databases for better SQL JOINs

In my company, our quality control organization has a two different SQL Server 2012 databases that capture manufacturing defects and component failures. Each database has a table and a column for "...
1
vote
3answers
104 views

Copy table structure excluding nullability into local temporary table

How can I copy the structure of a table into a temp table (or table variable) excluding the nullability of each column? Mainly I need to copy the column names and data types, but not nullability, keys,...
4
votes
3answers
1k views

Correct way to stop SQL Server (through automation)

Question Is it safe to start & stop SQL's services using PowerShell's Start-Service and Stop-Service commands? If not, is there a recommended way to start & stop SQL's services through ...
1
vote
1answer
90 views

Aggregate SQL Rows into single column

I would like to aggregate results of a column into a single row using MS SQL. I have create a sql fiddle which showcases the issue: http://sqlfiddle.com/#!3/384d5/2 Basically I would like all 'Tag' ...
0
votes
2answers
56 views

Limiting rows from a joined table

I have 2 tables Part and PartDtl. PartDtl contains one row for each order that has been placed for that part. PartNum | Description | ... 1234 | 1234 desc | ... 2345 | 2345 desc | ... ...
2
votes
3answers
88 views

Discover available HD storage from inside SQL Server

I have a SQL Server 2012 instance hosted in a VPS. I can't login on VPS's Windows directly. I know that there are multiple instances installed on that VPS. I have a query that shows me each DB's file ...