-1
votes
1answer
57 views

Inserting data based on different conditons - SQL Server

I have a table TN with 3 columns: Name School id ----------------------------------- maul 800 10001 maul 800 10002 paul ...
2
votes
1answer
297 views

Join tables in two databases make query slow? is better to partition db?

I have a table1 in db1 and table2 in db2 on SQL Server 2008 R2. If I make a select query joining both tables, it's really slow to get the results. A simple query like SELECT * FROM db1.dbo.table1 ...
1
vote
3answers
49 views

Removing chat history for a particular user from database

I'm currently developing a web chat application using SignleR and SQL server this is my database schema so far I've added an option where the user can Clear Chat history for a particular ...
1
vote
1answer
37 views

PostGIS vs. SQL Server for GIS data

So I'm recently starting at a new company and have a lot of ArcGIS users who seem really keen on going forwards with a PostGIS instance to serve some data to our customers. While I don't have an issue ...
0
votes
0answers
37 views

How I can monitor SQL Server 2012 databases to determine the security privileges that are called by different processes

Is there any tool that can identify the SQL privileges or roles that are being called on query by query basis. We need to know which ones are being used at each time on a Microsoft SQL Server 2012.
0
votes
0answers
41 views

table check constraint, greater than > not accepting

CONSTRAINT CK_BABY_YOUTH_CHILD CHECK (case when Passenger_Type='Baby' then Reference_ID >=0) This is my table check constraint, i have no idea why sql server is not accepting ">". Please ...
0
votes
2answers
54 views

Dynamic Table partitioning on a daily basis

I have a SQL Server database which contains two tables -- Acks and Logs. These two tables are related in logic but not in a relational database way. Basically, every message that comes in gets saved ...
0
votes
1answer
46 views

deleting a table referenced by many foreign keys

I have a table that I want to drop and create again, because I want to add the IDENTITY property to a column, wich is not possible directly. The problem is that I can't drop it, because my column is ...
0
votes
0answers
56 views

Technical documentation for Replication [closed]

My boss wants me to write a technical paper on replication, I don't know where to start or what to write about. We held a discussion and he talked about: Managed Code (we use VB.NET) Triggers ...
1
vote
0answers
56 views

Outer Apply vs Left Join Performance

I am Using SQL SERVER 2008 R2 I just came across APPLY in SQL and loved how it solves query problems for so many cases, Many of the tables I was using 2 left join to get the result, I was able to ...
1
vote
2answers
51 views

Users Characteristics

I'm really battling an issue where I have a Users table that has a growing number of user characteristics (regligion, smoking preferences, etc). The strategy I've used thus far has been to add a ...
1
vote
1answer
31 views

Break AG Cluster

I have a 2 node cluster setup and we use AlwaysOn HA with it. Currently we have two AG's and each one has three separate databases in each AG. We want to break the cluster and have three databases ...
0
votes
1answer
36 views

Frustrating SQL Server and VS Express 2013 Issue

I recently reinstalled Windows and am trying to set up SQL Server again with an existing database. I've tried installing SQL Server 2012 and 2014, and continuously get the same error. The error says ...
0
votes
2answers
26 views

Adding DATETIME() and Status column with xp_FileExist result

I'm trying to add a two columns in addition to the results of xp_FileExist. Here's my T-SQL: DECLARE @path varchar (100) DECLARE @file varchar (100) SET @file = '<location>\*.txt' SET @path = ...
0
votes
1answer
53 views

CROSS APPLY versus INNER JOIN

I was reading a lot about cross apply versus inner join recently. I tried writing some query and they both work kinda same, execution seem to be same aswell. Maybe someone with a deeper knowledge ...
1
vote
0answers
59 views

SQL select top X rows having sum limit

I am using SQL Server 2012, I have a table with a format such as : MyOrders : ID -> PK int Cost -> float Category -> int I want to get the following : Input : category (lets say 2). ...
0
votes
0answers
60 views

Stored Procedure's Commented line causing issues [closed]

We have a stored procedure which works as the sample mentioned below: CREATE PROCEDURE [dbo].[sdp_Test_Update] ( @ID int OUTPUT, @File_ID int, ...
1
vote
2answers
28 views

sp_publication_validation procedure doesn't seem to work properly

I am trying to use sp_publication_validation stored procedure to validate that my replication setup is working correctly. This procedure is pretty straightforward and is described here. I am running ...
1
vote
0answers
28 views

How to add SQL Server in networks list?

After changing my PC name and workgroup, I am no longer able to connect to SQL Server. Currently in my servers list I have only Home & localhost. Anybody know how to add server to networks list? ...
1
vote
0answers
48 views

How to handle many columns / variable schema?

I apologize in advance in case this question has been asked already. I'm working on revamping a reporting application used within my company. The requirements are: Support addition of new fields ...
0
votes
0answers
13 views

How to back out of mass update in SQL Replication [duplicate]

We have a database which is set up in Merge Replication. We accidentally updated hundreds of thousands of records in a large published table on the publisher database. We did is something like ...
-1
votes
2answers
25 views

My database is missing and disappeared after detaching it

I have detached my database from SQL Server 2008 and unfortunately I do not know its path and by my connection string I extract its exact name and searched it but it is disappeared from my computer. ...
2
votes
1answer
46 views

Foreign key, key split in two tables

I have to record a list of events made of action, reason (optional, may be multiple), user. I have a master table with all the valid action, and another with all the valid action-reason combination. ...
4
votes
1answer
360 views

Bad Design or Complicated Query?

Problem: For fun I am building a Database for lottery results to get some statistics off of. As of now I am only interested in a Pick 3 style lotto and might introduce more later. How would you ...
3
votes
1answer
41 views

Copy database and clear down data (including linked tables) older than N days

I have a sizable production database (140GB) on MS SQL Server 2012, which I'm trying to automatically download to our development environments on a periodical basis (every week or on demand). I'm not ...
1
vote
1answer
44 views

Restoring a database, changing recovery model

I regularly make a backup of my production database, then restore the same onto a test database, so developers can always have recent data for testing. The production database uses full recovery ...
0
votes
1answer
102 views

Why straight SQL query run faster than stored procedure?

I am facing-out a very surprising problem in SQL Server. The problem is when the query run in SSMS window it will return result in ~1 sec and when the query run through a stored procedure it will ...
0
votes
1answer
40 views

Logical problem with a database model

Beforehand the table names and columns are in spanish, my native language is spanish. I've got a database to manage the tickets sales of a trip that is made by a bus, the problem is that when i relate ...
2
votes
1answer
180 views

SQL Parameter Sniffing Possible Workaround

Our system has roughly 500 "Customers" that have extreme differences in record counts. Here is a (greatly simplfied) sample query that could return 0 - 100000 rows depending on the parameter passed. ...
0
votes
2answers
50 views

SQL Server 2012 - Insufficient memory to continue the execution of the program. (mscorlib)

I have a sql file, which is up to 180 Mb. When I try to open and execute it on Microsoft SQL Server Managment Studio 2012, I am getting this error. . What do do ? I researched on Google. And there ...
1
vote
1answer
43 views

Maintenance plan backup and reload the same database

I want in my maintenance plan every night to copy the production database to a backup, and reload the newly-created backup into a test database. By reading here: Restore database - maintenance plan ...
-1
votes
2answers
43 views

How to merge a column in single row in sql server

I have a following data: Comp_id | Cntm_nb | Seq_nb | Amount | Type 1 | 1 | 1 | 2000 | rent 1 | 1 | 1 | 200 | charge 1 | ...
0
votes
1answer
35 views

Query Rows That Have a Following Row That Meets Criteria

Will try to do my best to explain this, as I don't really know how to word this to search for an answer. I'm a constantly learning but still newish SQL user who thus far has been able to solve most ...
0
votes
1answer
45 views

Delete from table where not in another table using two columns

I am trying to get my head around this delete statement I am trying to accomplish. I understand how to delete from table where column not in ( subquery to table2) I have two tables with multiple ...
1
vote
1answer
77 views

SQL Server Multiple JOINS with Table Value Function - query never ends

I have a query with 4 joins using a table value function to get the data and when I execute it the query never ends. Issue Details Table valued function: CREATE FUNCTION [dbo].[GetIndicator] ( ...
2
votes
2answers
66 views

Database events that will cause deletion of index

In SQL server if we try to change a data type of a column having index ,then it deletes the indexes associated with that column and changes the data type . I was not aware of it and was faced problem ...
1
vote
0answers
53 views

A query that does a lot of reads, but plan is OK [migrated]

I´m experiencing a strange behaviour in a specific query in the SQL Server 2008 R2. I´ve got a query that does 19 million reads and is very time-consuming and when I try to check its cached plan, the ...
0
votes
1answer
68 views

Query for row combine

BEGIN declare @t1 table( date1 date, EmpID int, bnumber varchar(24), Name varchar(50), Depname varchar(50), mintime time, maxtime time, Status1 varchar(50)) insert into @t1 exec dbo.InOut2 ...
1
vote
1answer
36 views

Insert fail logs

Is there a way to view fail inserts to a SQL Server database? I am seeing that a number of my inserts are failing and I'd like to recover that data if it's possible.
0
votes
1answer
30 views

Relationship between two tables so their value changes together

First of all I'm not sure if this website is for purely experts but sorry if it is.. the main page was a little vague I was wondering if it'd be possible to have a relationship, for example, in my ...
0
votes
1answer
40 views

Script not emailing from Maintenance Plan/SSIS

I have created the following script to send emails from my plan but it isn't sending out. It works correctly in a query window and under an agent job. This is added to the plan as a 'Execute T-SQL ...
1
vote
5answers
182 views

What is the advantage of partition Date field into individual Year(int), Month(int), Day(int), Time(time) columns? [closed]

What is the advantage of partition Date field into individual Year(int), Month(int), Day(int), Time(time) columns? My manager said this is well known practice and query performance is good. Is this ...
2
votes
2answers
407 views

Is there any way to do a SELECT query without any optimization in SQL Server?

I am trying to test the speed of SQL server queries. However, once I do the query once, it becomes a lot faster. The database is live so I can not make any changes to it, only to the SELECT query ...
1
vote
0answers
13 views

How to cope with SQL Server 2012 vs SQL (Azure) Database sql files

I'm trying to port my system to SQL Database (Azure instance) from SQL Server 2012. I'm using Visual Studio 2013 and I have my .sqlproj with all the definition of my database inside. Given that a ...
3
votes
2answers
194 views

Can I update every datetime in bulk?

The current database assumes all times are local to the user. Now we're changing this so the database stores everything in UTC and our application converts the UTC time in the database to the correct ...
0
votes
1answer
45 views

How to deal with very large transaction logs in SQL Server

Here is my situation: I have being asked to deal with a SQL Server 2008 R2 database that has a transaction log that is several times bigger than the database itself. The database is in full recovery ...
-3
votes
3answers
71 views

SQL cache hit ratio [closed]

I have install SQL server, but when i check report of DB there is cache hit ratio which is 98.92%. Is it harmful for sql, if yes then how to reduce it.....? please give me solution for that. thanks, ...
0
votes
1answer
31 views

Script to Add a Job to a SQL Server DB

I want to add a job to my DB to make a back up weekly but i want to do it from an script, i've serched and with what i found i made this: CREATE SCHEMA job go CREATE PROC BACKUPS @dir varchar(max) AS ...
0
votes
1answer
44 views

Is it possible to create a function in SQL server to act as clause e.g. Where or Limit

I've found a simple way to mimic the limit clause is SQL server by using SELECT * FROM customers OFFSET 22 ROWS FETCH NEXT 5 ROWS ONLY I'd like to replace those two line with LIMIT(22, 5) e.g. ...
0
votes
2answers
48 views

Set default value for all columns with specific name within a database

I've got a database that includes an int column project_id on many tables, and I want to script setting the default value to a specific value for all columns with that name in the database. Note that ...