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)

1
vote
3answers
44 views

how can database snapshot to be used to recover data?

I know the logic behind database snapshot and how it works. But my problem is how can database snapshot to be used to recover data? can we take a backup of database snapshot and restore it in a new ...
1
vote
1answer
24 views

Using a join operation with conditionals

I have two tables that I'm working with in my database. I am using SQL Server 2014. One is 'versions', that contains version_id, version_number, start_date, end_date and server_id. The other is ...
0
votes
0answers
16 views

Database migration from SQL2005 to SQL 2012. SQL groups Creation with Securables

I moved 7 databases to MS SQL server 2005 to MS SQLserver 2012. Both SQl are on different servers. I copied window level user group and created SQL server level groups in SQL server 2012. Now my ...
1
vote
2answers
27 views

Using Variables to contain column names for SQL Server Merge statemtns

I'm trying to automate the column list grab for a merge job, and running into a bit of a head scratcher. I don't want to have to manually type out all of the column names, and thought I may be able to ...
0
votes
0answers
18 views

BallPark Upgrade Cost SQLServer 2014 standard with SA to Enterprise Edition with SA [on hold]

Anybody know a link or has a ballpark way of calculating upgrading from 2014 Standard Edition SA to 2014 Enterprise edition with SA? Failed when searching google land in this endeavor.
-1
votes
1answer
44 views

How can I do a SQL Server 2000 bak?

I have 2 databases .mdf SQL Server 2000, and I need to restore them on SQL Server 2014. After some research, I saw that the best approach is making a .bak of this 2 files. Well, I need to install SQL ...
0
votes
1answer
16 views

Generically get all related records from SQL Server Database based off of Primary Key of one table

In Sql Server it is possible to visually see all relations a table has by creating a diagram of one table and right clicking and selecting 'Add Related Tables.' Is this also possible to do for one ...
1
vote
1answer
16 views

Looking for a better way with Reporting Db server

I have a "reporting" db server which is basically a clone of production using backup and restore in a stored proc to handle restore , user , permission etc. Backups/restores happen 1x per day at a ...
0
votes
1answer
14 views

Granting only SELECT VIEW permissions to specific Views to a specifc user on a MSSQL database

I have landed in a scenario were I have to let a user inside a database which is not his. Hence I want to make sure that he is only able to SELECT from the views that I deem he can read from. I have ...
0
votes
1answer
22 views

data validation Datawarehouse ETL

Need a suggestion from Datawarehouse and ETL experts. I have a project which has bunch of fact and dimension table, and we wire the facts using surrogate keys to dimension (religiously following ...
1
vote
3answers
82 views

Trim Trailing Whitespace, Tab, Newline, Carriage Returns, etc

I am working with SQL Server 2008 and I am looking for a function like ltrim and rtrim which will also remove leading and trailing tabs, double spaces, carriage returns, line feeds, etc. There are a ...
3
votes
1answer
258 views

Can see other user's databases in shared hosting

This looks like a security concern but I do not know enough about SQL Server to know. Using a shared hosting service, if I go to restore a database I'm able to see other user's databases. I'm not ...
0
votes
1answer
33 views

List of queries run

I'm looking for a DMV query for SQL Server 2008 R2 which shows me all queries (full history) run by a specific user. I have this code for now: SELECT * FROM sys.dm_exec_query_stats qs CROSS APPLY ...
-4
votes
0answers
14 views

show invalid object name [on hold]

when this code runs on mysql database then fine but when this code run on sql server that showing error com.microsoft sql server exception invalid object name... private void ...
1
vote
1answer
38 views

Capitalize only the first letter of a name

I have a table Vendors that contains a column VendorContactFname, which is written in lowercase. I want to capitalize only its first letter. I am thinking of concatenating an Upper on the first ...
2
votes
1answer
29 views

Relating 2 tables with possible wildcards?

I am having trouble getting the desired results when trying to relate the following tables. NULL in the following table essentially means that if it is not an exact match with another row then choose ...
0
votes
0answers
15 views

Create update Trigger

I'm trying to create a trigger that whenever a software package is installed on a PC, the person who installed the software needs to provide data for pack, tagnum, and instdate, and the softcost field ...
1
vote
1answer
24 views

Can mirror and witness have same port number? [on hold]

When configuring database mirroring, the mirror and the witness have generated the same port number. When I hit next, it errors out with: End points for instances for the same server must use ...
1
vote
1answer
30 views

Attach corrupted database

In a little C# tool, I use an a mdf file to save my data. The file became inconsistent, which isn't really a problem as there only a few changes since my last backup. Anyway, I would still like to ...
3
votes
1answer
29 views

Security concerns on SMTP in SQL Server

In my company, while I try to get the ports opened to connect to my SMTP server from my SQL Server running on Windows Server 2012, I get a reply saying that it is a security concern to open ports ...
-1
votes
0answers
14 views

error in parallel query execution-single row subquery returns multiple rows [on hold]

I am getting the error "error in parallel query execution-single row subquery returns multiple rows " sometimes while executing an sql query, while most of the times the same query runs without any ...
1
vote
1answer
25 views

sql getting sum of calculated columns

How can I get the sum of TotalAmount as single value for example Product Name UnitPrice Quantity Discount% Amount SharingCost% ShippingCost CustomsCost TotalAmount pro1 ...
0
votes
1answer
10 views

A different number of AFTER INSERT trigger alarms in SQLite and SQL Server

I have trigger CREATE TRIGGER [Foo] AFTER INSERT ON [Bar] BEGIN UPDATE Log SET count = count + 1; END When i execute query insert into Bar (ColumnName) values ('SomeValue1'), ('SomeValue2'), ...
5
votes
2answers
249 views

Are cursors/While loops the only way to make administrative changes to multiple databases?

I specifically want a programmable way to change the recovery model of all the databases on a server, and i know this solution can be applied to all 'Alter Database' commands. While I know SMO in ...
0
votes
2answers
24 views

Using Select Statement to get column name and table name from the same table

I have a table containing 2 Columns : Column1 (table_name) and column2 (column_name) like this : (Column 1) (Column 2) |Column_Name | Table_Name | -------------|------------| ...
5
votes
1answer
190 views

Why can a differential backup not be copy-only?

I have noticed that copy only backups does not allow for differential backups. What is the reason the copy-only backup option is disabled for differential backups?
-3
votes
0answers
18 views

i need to know some advantages of field size [on hold]

Can you explain some advantages of field size. I have already tried to change the number of characters. This is because changing the number of characters reduces the amount of space wasted in the ...
4
votes
0answers
23 views

In SSMS, is “Navigate to” (Ctrl+,) of any use?

In standard Visual Studio 2012 or higher, IDE window called Navigate to... (Ctrl+,) offers all useful objects in scope of currently open project (see samples) getting increasingly filtered as I am ...
1
vote
0answers
51 views

To find SQL Server is actually used or not?

I have an SQL Server 2012 and a 2008R2 running in my environment. I need to decommission the server if the server is not actually being used. I did go through this and this where connection count is ...
2
votes
2answers
60 views

SQL Row concatenation with XML PATH and STUFF giving aggregate sql error

I am trying to query two tables and get results like the following: Section Names shoes AccountName1, AccountName2, AccountName3 books AccountName1 The tables are: CREATE TABLE ...
4
votes
1answer
68 views

When executing a command via xp_cmdshell what user issues the command to the system?

I'm executing the following command to stop a service on a remote server from within a stored procedure in SQL Server. ---------------- -- Stop Service ---------------- SET @Command = 'sc \\' + ...
5
votes
1answer
79 views

Conditionally add an index to a temp table

I have a stored procedure that looks something like this: SELECT columnlist INTO #temptable FROM Table JOIN lotsofothertables WHERE severalconditions UPDATE anothertable SET column = ...
0
votes
2answers
43 views

Migrate SQL server data to new schema

I have a database that was originally created by a couple of people for a small business unit (about 8 staff and 10 customers) in MS Access. The original 'developer' was a non-geek who had been sent ...
0
votes
1answer
32 views

How to find the AD user that logged in to SQL Server using SQL Login [duplicate]

Some users are logging into database servers locally, opening SSMS and logging in to SQL Server using SQL logins to run queries. How can I find the AD user that logged in to SQL Server using a SQL ...
0
votes
0answers
16 views

MS SQL data synchronization question

I'm in charge of modifying an application which was intended to run Microsoft SQL Server Compact 3.5. The application must run on a local database during fieldwork when there is no network ...
0
votes
3answers
43 views

Minimum value within a set (or window) within a three column table

I only have SQL Server 2008R2, therefore I do not have all the window functions available since SQL Server 2012. I have a table that looks like this: I would like to retrieve a result set like ...
2
votes
1answer
129 views

How can I speed up a stored procedure?

Here is an interview question I just had. I would like to know what a good answer to this would have been and what the different options would be. We have a stored procedure that is taking 26 ...
0
votes
1answer
30 views

Restore a database with compression on a non-enterprise edition SQL Server

Is it possible to restore a compressed an object from backup without the Enterprise Edition? I'm getting the following error after a RESTORE DATABASE operation. Msg 3013, Level 16, State 1, Line 2 ...
2
votes
2answers
58 views

Completion of SQL Job triggers start of job on a different SQL Server

I want the completion of a SQL Server agent job to trigger the start of a job on another server. More specifically, I want my SSRS server to email a subscription report whenever an FTP/Import job ...
0
votes
0answers
22 views

SQL Server Job does not execute when scheduled, but does execute manually, how do I get it to run as scheduled? [duplicate]

I am running SQL Server 2014 SP 1 CU 5. The job did work in the past. The schedule is enabled. The account it is running under is an ADS account which has sysadmin rights and has delete rights to the ...
0
votes
1answer
42 views

Same query same data different server different query plan

I have a query that hits a view, which references other views etc...several levels down. The query plan is a bit complex. I run the query on 2 different servers. On both servers, the number of rows ...
3
votes
2answers
49 views

Define a proper index for a table

I have a table with millions of rows and something like 20 columns. This table have an unique identifier as primary key, but the most likely query is based on three varchar columns (col1 and col2 of ...
5
votes
1answer
480 views

Does a single rollback affect all transactions?

When I run the following script: begin transaction select XACT_STATE() select @@TRANCOUNT begin transaction select XACT_STATE() select @@TRANCOUNT begin transaction ...
0
votes
2answers
34 views

How to separate values from one column into two columns in SQL Server [on hold]

I have this dataset as input: Name Contact No ------- ---------- Deepika 75865558 Deepika 207586558 Rnveer 746655558 Rnveer 946655558 vaibhav 2356841 vaibhav 6655558 I want to get ...
0
votes
0answers
21 views

Can't connect to Database in Network using MS SQL 2016

I'm completely new to MS SQL Server and trying to connect to a Database in my network. I can find it, but everytime I am trying to connect it says username or password would be wrong. What I have ...
-1
votes
0answers
26 views

How to configure table with BLOBS (type image)?

I am about to overwork a table storing BLOBs in an IMAGE column combined with those file's metadata during a database maintenance. Lot's of the BLOBS will be removed during this process. We are ...
0
votes
0answers
9 views

Is this work flow suitable for Amazon RDS?

I am considering to set up a MySQL database via amazon web services (AWS). Consider the following steps which characterize my workflow: There is a daily data inflow into several AWS EC2 instances On ...
1
vote
1answer
28 views

Constraint column value based on another column? SQL Server

i am trying to set my defaults column Y or N based on membershipType column. There can be only one Y in defaults column based on the 3 different value in membershipType column. Other than that, others ...
1
vote
2answers
30 views

SQL Server — More efficient alternatives to repeating an (almost) identical subquery

I need to improve the efficiency of multiple subqueries within a WHERE clause. The context is a report generator on an existing product. The only input I can provide is the WHERE clause. I have 3 ...
-1
votes
1answer
18 views

Data Quality Service (DQS) and Master Data Services (MDS) [closed]

Best practice question. Is anyone using one of these in production? Can you share your experience and the business need you were solving with it? I am learning about them and do not really see the ...