Microsoft's SQL Server is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. It originated from the Sybase SQL Server codebase, which is why both products use the extension of SQL called Transact-SQL (T-SQL).

learn more… | top users | synonyms (2)

0
votes
1answer
34 views

Can we create a stored procedure to copy detached .mdf and .ldf files from original location to new location?

I am trying to create a script to attach database, move .mdf and .ldf files to new location and then attach the database. I created a stored procedure to detach and attach the database. Can I get a ...
2
votes
1answer
179 views

How to allow to execute stored procedures but not writes?

I would like to set up a "reading" user on my SQL Server 2012 instance. I would like to allow him the right to execute any stored procedure, or function, or direct SQL statement, which retrieves data ...
1
vote
1answer
46 views

Stored procedure - problem with merge - Insert

I am calling a stored procedure from my c# code . The procedure works fine for update, but fails for Insert. Is the following merge-insert procedure code correct? Any help is appreciated. Here is ...
1
vote
2answers
62 views

How do I return data from a table where the data is the max date of the previous month's data submissions (-1 of current date)?

I have a stored procedure where I select the latest/max submit_date data for a tracker_date and client from a source table called Tracker_Live, and insert it into a new table called ...
2
votes
3answers
206 views

Finding Database Default Locations

I am working on creating a script to restore database from a backup file to default location of an instance, which is set away from system databases installation folder. Currently, I'm using to find ...
1
vote
2answers
143 views

ONLINE vs OFFLINE index rebuilds

I am looking for an opinion, which I know is usually frowned upon, so my apologies in advance. I'm currently in an environment where every instance is SQL Server enterprise edition. The maintenance ...
1
vote
1answer
85 views

Offsite Log Shipping

We currently use CDC to replicated our Production DB offsite (Microsoft SQL Server 2008 R2), but using CDC and the way we process the files is very unstable. Also note that the two servers cannot ...
5
votes
1answer
232 views

View designer strange join syntax

I have a data warehouse with a lot of views built in with the SSMS view designer. Viewing the syntax, the FROM clauses are unintelligible to me because the ON statements do not follow straight after ...
3
votes
3answers
110 views

A way to clear/restart virtual memory creep automatically?

I know it's not good practice to do this, but my company cannot afford me trying to find a proper solution to our problem. I've read this and I could do the same with SQL Server 2005, but I was hoping ...
-2
votes
2answers
71 views

Install SQL Server 2008 R2 with one click [closed]

How can I install SQL Server 2008 R2 without wizard, just install and voila, install on PC?
0
votes
1answer
65 views

OS Paging too high in sql server

For one of my servers with below configuration: Total RAM: 32 GB CPU: 8 Max Server Mem: 22.5 GB Min Server:: 4 GB Edition: Enterprise Edition with 2k8R2 installed on SP3 ...
3
votes
2answers
66 views

Is there a way to grant SELECT for every database (including new ones) at a server level?

I have a unique (well, I think it is unique) situation where databases (yes, entire databases) can be created more or less dynamically. Ignoring the obvious issue with that, I need to be able to ...
-2
votes
1answer
20 views

Delete into SQL Server loop [closed]

In case of repetition periods, need to delete the second occurrence (15 to 15 minutes), but the query always returns all or nothing. DECLARE @DatAteTemp DATE DECLARE @HorAteTemp TIME DECLARE ...
1
vote
2answers
74 views

Reuse a complex non-deterministic expression in SELECT and WHERE clauses

I have a query like this: -- This is inefficient, and may even be wrong if expression is nondeterministic SELECT TOP 10 team_name,score_points=<big expression> FROM teams WHERE <big ...
3
votes
2answers
104 views

Changing metadata changes query output issue [duplicate]

Recently stumbled across the following problem: changing metadata changes query output. Here is how to get it. CREATE TABLE [dbo].[prod] ( [ID] [tinyint] NOT NULL, [values] [tinyint] NOT NULL ) GO ...
0
votes
3answers
45 views

Reset Key Names to Defaults?

I'm working with some tables/columns that were renamed at some point, but the names of the primary/foreign keys are still based on the previous names. In SSMS is there any (preferably automatic) way ...
1
vote
2answers
62 views

Downgrade SQL Server Enterprise Edition to SQL Server Standard Edition

There is a requirement in our project where they want to evaluate if it is possible to downgrade SQL Server from Enterprise to Standard edition and if a server can be decommissioned. Kindly guide me ...
0
votes
1answer
24 views

SQL Server 2012 Replication, how to ignore action with specific trigger?

SQL Server 2012. Database is in merge replication, no conflicts presented. Current example is simply for understanding, but real schema is very huge to describe. Schema and trigger at SQLFiddle for ...
2
votes
0answers
23 views

Replication stopped working, no errors

I have a TOP server (SQL Server 2012) with a merge replication to around 4 other servers. When I subscribe to the publication, everything is downloaded fine to the subscriber. The insert of one of ...
2
votes
3answers
215 views

Cascade primary key update to all referencing foreign keys

Is it possible to update a primary key column value with cascading the update among all the foreign keys referencing it ? # EDIT 1: When I run followinq query select * from sys.foreign_keys where ...
0
votes
1answer
34 views

Unable to install

Unable to install SQL Server 2008 in windows 8.1 64 bits it asks for .Net Framework 2.0 but I have already installed .Net Framework 4.5 with the OS.
1
vote
1answer
79 views

Does “Synchronous-Commit Availability Mode” ensure consistency between Replicas?

If one refers to the MSDN documentation, on Synchronous-Commit Availability Mode, you may read: Under synchronous-commit availability mode (synchronous-commit mode), after being joined to an ...
0
votes
2answers
58 views

SQL server permissions during installation

I'm trying to find out when a SQL server installation grants permissions on the OS. I know that the following permissions are giving during setup msdn article about permissions. However what I don't ...
0
votes
0answers
36 views

The underlying provider failed on Open. Error in Windows Service

I have a Windows Service(c#) that receives data and inserts it into DB using Entity Framework 6. Database is SQL Server 2014 Enterprise Edition. Both (Service and DB) are hosted on VPS( Windows Server ...
1
vote
1answer
40 views

Which Indexes in which situations is more efficient in SQL Server 2012

I use SQL Server 2012. I want know when I want to know in what situation I have to use CREATE NONCLUSTERED COLUMNSTORE INDEX .... and in what situation I have to use Create NonClustered Index... ...
1
vote
1answer
105 views

T-SQL View — How to 'pre-fetch' schema using scalar function, then populate using table query

I have an application that uses T-SQL views. A number of these views are quite complex, joining data from many tables. To avoid column-name collisions, the views often employ table-scalar functions to ...
1
vote
1answer
31 views

Is it good or bad practice to have a fact table relate to the same dimension table multiple times?

I'm new to DW/BI, and this seems like a pretty basic question, but I can't seem to find a good answer. I have a fact table that would have more than one date associated with it, so I was thinking ...
0
votes
1answer
41 views

Importing a Foxpro Database

I have a Fox Pro database (one DBC and a bunch of DBF files) that I want to import into SQL via the Import and Export wizard. I downloaded the FoxPro ODBC driver. I managed to get to the screen that ...
2
votes
1answer
79 views

Prevent Subscription to report from running on a holiday

I have a SQL Server that I am using for building and distributing reports. I have built all the packages for importing data as needed as SSIS packages. These reports only need to be run after the ...
2
votes
1answer
64 views

Why choose a top query and temporary table instead of a cursor for a loop?

When it comes to looping over a large set of data in T-SQL, the majority of examples I see on the Internet use a pattern like this: declare @someVariable int declare @remainingRows int select ...
1
vote
1answer
33 views

How to find missing data from one table that is a join of 2 other tables

I have 2 tables, stock and location, with a third table that records the level of stock at each location, stock_loc_info. Each stock item should have a record for each location. What SQL query ...
2
votes
1answer
74 views

SQL Hard Drive Config?

I am setting up new server and am a little confused in my research of HD configuration. My main question is : Is it recommended to have the Trans Logs and DB logs (ldf) on separate spindles or can ...
2
votes
2answers
61 views

space usage on sys.allocation_units and sp_spaceused

It is a known fact that the DMVs dont hold accurate information regarding number of pages and count of rows. However, when you have the stats updated, I can't see why they wouldn't. I am working on a ...
1
vote
1answer
39 views

SQL Server 2012 Execution Plan

I was reading through Kendra Little's post on www.brentozar.com http://www.brentozar.com/archive/2013/08/query-plans-what-happens-when-row-estimates-get-high/ In the post, Kendra mentioned that she ...
0
votes
2answers
65 views

60 minutes to shut down sql server service?

We recently merged with a new company and they have a server that has 265 DBs on it (6.6tb of mdfs). Shortly after we merged the other DBA said it takes 60 minutes to shut down the services which I ...
4
votes
6answers
143 views

Select rows with same id but null and some other value in another column for that id

I want to get only rows having a value NULL and some other value than NULL for a particular username column. If both rows have null for that particular username or both have some values other than ...
2
votes
1answer
23 views

How to format documentation in MS_Description extendedproperties?

I'm using a 'MS_Description' extended property to document parameters in a stored procedure. This parameter's documentation requires more structure than just plain text. That is I would like to ...
0
votes
1answer
34 views

Generate Schema and Data to SQL script and Run it on another DB programmatically

I can manually generate a schema with data via Table Name > Tasks > Generate Scripts... But it is possible to create a schema+data single sql file backup of a database and run it on another database ...
1
vote
2answers
71 views

Writing a large update/delete script that doesn't provoke locks

While running a T-SQL script that is performing massive amounts of deletes, I had the unpleasant experience of causing some sort of lock contention that prevented inserts of data in some tables for ...
9
votes
2answers
912 views

What significance does an index_id < 256000 have?

In a certain tutorial I read the author is filtering sys.indexes based on the predicate index_id < 256000. What does this accomplish?
9
votes
3answers
146 views

What is a deterministic method for evaluating a sensible buffer pool size?

I'm trying to come up with a sane way to understand if the max server memory (mb) setting is appropriate (either should be lower, or higher, or stay the way it is). I am aware that max server memory ...
0
votes
0answers
23 views

Controlling SQL Backups From Two Machines

I'm far from a DBA, and don't really have a great understanding of backup chains, but I was asked the following question by a network administrator, and wanted to be sure that my answer was correct. ...
0
votes
0answers
31 views

How to tell which process in SQL Server I should kill?

I am having an issue with an application as it is running supper slow. I don't know if it is a database issue or something else as the is nothing that I can find to be the issue. I tried select * ...
8
votes
2answers
186 views

SQL Server : how to create user with access only from specific HOSTNAME or IP addres

I have one stupid app which I rely on, which has hardcoded connection string inside. To increase security of my SQL Server I'd love to make SQL users same as one hardcoded inside app, but I want to ...
0
votes
1answer
21 views

convert update field second to time

I have 2 fields ( about 1000 records) name FROMTIME and TOTIME. Both fields will have time in seconds (for example FROMTIME = 20520 and TOTIME = 39360). I would like to convert and update these ...
0
votes
1answer
35 views

Dynamic Pivot with overlapping years

I have looked and cannot find how to show the last # months in a pivot table. Everything I seem to run across codes months statically. I'm seeking a solution that shows something similar to the ...
4
votes
1answer
267 views

Restarting database server or just the database

I am an application programmer. We have a SQL server 2012 instance that hosts many related databases(around 12 databases). The vendors did some changes to one of the database and the application and ...
1
vote
1answer
63 views

How to get the dependent entities (referencing entities) for an User Defined Function (UDF)

We have a database that has been copied, including stored procedures and some user defined functions. I'd like to check whether a UDF is being used. Is there a way to see which stored procedures ...
-5
votes
1answer
54 views

Select Top Ten Each Group [duplicate]

This my table and and my query ! MyTable This is My query select CellId, PathId, channel, sum(Duration) as min_duration from HourlySummary group by CellId, PathId, Channel order by cellid, ...
0
votes
2answers
50 views

Can an EXISTS clause be improved when the condition is checked for the same value multiple times?

Assume that I'm modelling a Blog engine. Blogs have n Posts. Each User can be granted a role on different Blogs (Admin, Approver or Editor stored as enums/ints). Each Post can have a State (Draft, ...