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
2answers
33 views

Add a flag when certain conditions are met

I have a table where when an employee works LEAVE1 and LEAVE2 paycodes on the same day then in the new column called 'FLAG' we need to put a 1 for LEAVE1 and a 2 for LEAVE2, when these paycodes are ...
0
votes
2answers
25 views

Return NULL values in a date group by

I have the following query: SELECT DISTINCT COUNT(CD_BarCode) ,CD_Carrier ,SUBSTRING(CONVERT(VARCHAR,DT_Arriving,103),1,11) Date FROM TB_AGIL WHERE ...
4
votes
2answers
184 views

Tell SQL Server a query is ad hoc and not to optimize based on it

Is there a way to run a one-off query against a production SQL Server database and tell it not to make any future judgments based on that query. E.g. Store execution plans, recommend indexes, etc. ...
10
votes
3answers
220 views

SQL Server 2014 schema changes in 24/7 multi user environment

We have SQL Server 2014 Enterprise installed to run a database which should be available 24/7. Our database is huge enough (200gb +). Also we have a lot of services that hits our database every minute ...
-3
votes
0answers
14 views

sql server stored procedure clockin

how to create a stored procedure with clockin,clockout columns and I want to show the time worked from them and the min_leave_time when user clockin and out for breaks on a 8 hr. shift with lunch only ...
2
votes
1answer
22 views

Availability Group environment clone

I've been assigned a project where we have an active secondary environment that I'm confident that Availability Groups would address but have some questions that I hope someone can answer for me. ...
0
votes
2answers
42 views

How to create Date table

I have problems when I try to create my DimDate. That's what I have tried: CREATE TABLE [dbo].[DimDate] ( /*[ID] [int] IDENTITY(1,1) NOT NULL--Use this line if you just want an ...
2
votes
3answers
2k views

Copying distinct rows from one table to another

In SQL Server, I can copy one table into another by doing: Select * into desttable from sourcetable However, there are duplicate rows in sourcetable and I would like to just copy distinct rows. How ...
1
vote
0answers
52 views

Routing data from one SqlServer to another

Is there a way in SqlServer 2012 to have data being written to one table routed to another SqlServer on another host ? To clarify, we are using Hibernate Envars to write audit logs. Hibernate Envars ...
19
votes
4answers
349 views

In Sql Server, is there a way to check if a selected group of rows are locked or not?

We are attempting to update/delete a large number of records in a multi-billion row table. Since this is a popular table, there is a lot of activity in different sections of this table. Any large ...
7
votes
2answers
139 views

Windowing offset based on time stamp

I'm writing a query that will be used to page results for a social feed. The concept is the mobile app will request N items, and provide a starting datetime which I have called @CutoffTime below. ...
3
votes
1answer
53 views

ASP.NET & SQL Server 2012 timeouts once a month

We have an intranet site which works fine, except one day a month. There are slow queries, unoptimized tables, tables with ~8 million records, etc. but daily usage is fine, although some ...
1
vote
0answers
24 views

Transactional replication taking hours to replicate

I have a bunch of tables replicated from my_publisher to my_subscriber via my_distributor. Some of these tables, not all of them, when updated on my_publisher, take a couple of hours to be updated on ...
2
votes
1answer
33 views

Meaning of SERVERPROPERTY ('ResourceLastUpdateDateTime')

I have researched a while, a lot of articles name it and tell us to use it - but none really explains the meaning of the date and WHEN exactly it changes. Does anyone know? Samples for articles not ...
0
votes
2answers
114 views

I need to insert data from one table to another after casting the values

i have #temp table containing all details to insert into table(named:Customer) The column names of two tables are exactly equal,but datatypes are different.So i need to cast it before insert into ...
3
votes
1answer
174 views

Gigantic gaps in IDENTITY column

This question is about strange behavior in SQL Server 2008 R2 SP3 Standard Edition x64. I have read many questions about IDENTITY increments in SQL Server and strange gaps between them. But basically ...
4
votes
1answer
160 views

Running a sql server query with as little impact as possible

I'm looking to create some basic scripts that are aimed at running on production systems. I want them to run with as little impact as possible. They shouldn't affect performance whenever possible, ...
2
votes
1answer
30 views

Finding out what permissions are required by the SQL Server Agent Jobs

I've been looking at this for a while and I can't work out an easy way to do this. As it stands every job in the database runs under SA level rights (horrifying thought) I'm sure some of the jobs ...
2
votes
1answer
140 views

Can SQL Server 2008 R2 get email name resolution from Office 365?

We just moved from an on premise Exchange server to Office 365's Exchange Online. My question is, is there any way to still get email name resolution from Office 365? I have many stored procedures ...
1
vote
2answers
42 views

Join with comma separated values in SQL Server

I have a table [CourseMaster] LIKE CourseId CourseName ----------------------- 01 ABC 02 DEF 03 GHI 04 JKL 05 MNO 06 PQR 07 ...
2
votes
1answer
363 views

Database design for a table with both bulk insert and single row insert

I have to design a table where records will be inserted in two ways. Bulk insert from a batch process from a delimited text file between 2 - 3 million rows in a short burst. Later the same records ...
2
votes
1answer
123 views

How can client retrieve SQL Server pubic SSL certificate?

Can a user retrieve the connection certificate for an SQL Server instance (similar to how someone can retrieve an HTTP certificate)? If so, how? Context If encryption is requested by the SQL Server ...
3
votes
1answer
23 views

Wide clustered index vs multiple narrow nonclustered indexes?

Say I have a contrived Student table like so: CREATE TABLE Student ( Id IDENTITY INT, SchoolId INT NOT NULL, FirstName VARCHAR(20) NOT NULL, LastName VARCHAR(20) NOT NULL ) ...
1
vote
1answer
79 views

What collation to use for Ukraine?

We have an accounting program with an SQL Server database and would like to start a Ukrainian version. I am not sure which collation to use: Ukrainian or Cyrillic_General? With a non-technical ...
-1
votes
3answers
22 views

Selecting multiple rows as one row with “AS” [on hold]

If I have a table of users, for example, and I want to include the users in a query like so: SELECT gameId, player1id, player2id, users.username as player1, users.username as player2 FROM players, ...
1
vote
1answer
54 views

Determining the specific command type in a DDL trigger

Given strings corresponding to DDL commands, how can I determine which DDL command (column addition, constraint addition etc.) it precisely is? I have a DDL trigger on a database that will be fired ...
8
votes
1answer
5k views

How to trace SQL queries which are crashing SQL Server

We have a SQL Server 2008 database server (it happens to be running under MS Failover Clustering, but I don't think that is relevant here). Our application runs Hibernate for DB access, and since we ...
9
votes
5answers
2k views

SQL Server command line usage? Is it possible?

I've been trying to use the SQL Server Management Studio 2008's built in "Solution Explorer" to manage a project and after 2 weeks of struggling with it, I've decided I don't really care for it. It's ...
1
vote
1answer
76 views

Replication throw an error after failover mirror partner is down in SQL Server

Received an error mentioned below after failover when mirror partner is down. Error : to fail over to a database which is not configured for database mirroring. code: 22037, text: 'Invalid ...
1
vote
1answer
964 views

SSIS - insert system date variable as a execute sql task parameter

I am trying to insert the system:starttime variable into a table by passing a parameter into an execute sql task. I dont have much knowledge of SSIS data types, and I am currently having trouble ...
7
votes
2answers
59 views

NoSQL : What is unstructured data?

we are currently running at the edge of resources with our mssql server based solution. We have now many traditional options regarding the next move to tackle the load: buy faster CPUs and IO ...
0
votes
0answers
33 views

SQL SERVER 2014 windows administrator locked and sa password lost [duplicate]

I am missing the sa password for a SQL Server 2014 instance. Unfortunately the Windows Administrator user is also locked. How can I reset my sa password?
1
vote
1answer
181 views

Error updating zoned field from SQL Server stored procedure linked server to iSeries

I'm trying to update a table on an iSeries (AS400) within a SQL Server stored procedure using linked server, but it is failing when trying to update a column defined as zoned. In my stored ...
3
votes
0answers
42 views

Different Disk Drive Same Backend Storage

I have a database running on a VM which is getting hammered during a large load, in particular I can see waits of WRITELOG happening. My initial thought is to split the files out on to their own ...
0
votes
1answer
47 views

SQL server 2014 Transaction Log Backup fails

I have setup a Maintenance Plan for my SQL server 2014 Database. This Plan Generates Full Backup every Sunday, and Differential backup every Day and Transaction Log every hour. This Maintenance plan ...
1
vote
1answer
60 views

Scramble the data output of a stored procedure

I have a stored procedure that produces data for a call center system every morning. However, the data is sent in the same order daily. Is there a way to send the day in a different order every day ...
0
votes
1answer
28 views

SQL Server 2012 - Can't detach database on mirror server

I'm running SQL Server 2012 in a mirror configuration and I need to move the mirror's transaction files. I deleted the mirror setup on the primary but I can't detach the databases on the mirror, the ...
-3
votes
0answers
24 views

database is not getting restored second time with this query [on hold]

USE master GO ALTER DATABASE Tfs_CoeTest SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO RESTORE DATABASE Tfs_CoeTest FROM DISK = 'D:\Backup123\Tfs_CoeTest' WITH MOVE 'Tfs_CoeTest' TO ...
2
votes
2answers
9k views

How to restore SQL Server database with mirroring

I have SQL Server with mirroring. I am trying to restore the database using the command: USE [master] ALTER DATABASE [CentralStorage] SET SINGLE_USER WITH ROLLBACK IMMEDIATE RESTORE DATABASE ...
2
votes
2answers
151 views

Sql Agent Jobs executes too slow

I have posted a question like this before but is seems that I did not explain the whole story clear. So I made this one to explain it in details. Here's the stored procedure USE [xxxx] GO /****** ...
0
votes
0answers
22 views

How to install SQL Server Agent in existing SSMS [on hold]

I have been working on SSMS for Data mining, Now I would like to schedule a job. Where I am unable to find SQL Server Agent to schedule a job. Can any one help me how to get SQL server Agent into ...
2
votes
2answers
25 views

Error 4108: Windowed functions can only appear in the SELECT or ORDER BY clauses

The error in the title is produced when add the second condition in my where clause. I understand the error, have tried using subqueries as seen in other posts to fix this but no luck. Does anyone ...
4
votes
1answer
45 views

Zero Rows return on quering DMV sys.dm_os_performance_counters

I have a user on SQL Server 2014 Standard Edition (RTM) with SYSADMIN role with Server View State Permissions but when I execute DMV sys.dm_os_performance_counters it return no record. Any idea what ...
2
votes
1answer
52 views

How can I compare the number of transactions in the first weeks or months of different stores

I need to make a comparison of the number of transactions per week and month of different stores since its opening date. The problem is that the stores has a different opening date. So, The idea is ...
8
votes
1answer
601 views

Why is the page life expectancy 0 (zero) on SQL Server 2005

We have been wanting to know the page life expectancy for our SQL Server. So we look at the counter using Perform. The value is ZERO and never changes. I thought there must be some bug, so I checked ...
7
votes
3answers
22k views

Query to report disk space allocation and used space

We are using 6 databases in total for an application, and we can only share 4TB of space among all 6 auto-grow databases (via SAN storage). I'd like to write a query (report) for a single database ...
5
votes
3answers
1k views

Possible to detach a database from SQL Server while retaining file permissions?

When a user detaches a database from MS SQL Server, it sets the owner of the data and log files to that user. It also removes all non-owner permissions from the files. This is partially explained at ...
3
votes
1answer
40k views

How to determine used/free space within SQL database files? [duplicate]

I normally use the following method to determine the free/used space within each file of a database: Select *, fileproperty(name, 'SpaceUsed') as Used From dbo.sysfiles This returns total and used ...
4
votes
1answer
103 views

SQL Server data folder access rights

I did a fresh SQL Server 2014 install. Next, I wanted to attach some databases from a previous SQL Server 2012 server. I copied all mdf and ldf files to the data directory, but when I tried to attach ...
0
votes
1answer
293 views

Found errors in table after executing DBCC CHECKTABLE command

I am trying to alter table to add primary key ALTER TABLE GeoCity ADD CONSTRAINT PK_GeoCity PRIMARY KEY(locId) and got this error message Msg 1750, Level 16, State 0, Line 1 then I run ...