1
vote
1answer
99 views

Why dropping all foreign keys from a script is not working?

I have sysadmin rights on a SQL Server 2008 R2 box. I found a script that can drop all foreign keys and re-add them for us when we need to after a testing import. So I execute the below code with no ...
0
votes
1answer
62 views

How to schedule jobs in Sql server 2008 for less than 10 sec?

I want to run a job every 3 seconds, however in SQL Server 2008 we cannot define an interval of less than 10 seconds. The job is used to insert/update visitor information, and segmentation ...
1
vote
0answers
36 views

What will do After Press F5? [on hold]

select * from Employee; Name id Col1 Col2 Row1 1 11 1 Row2 2 12 3 Row3 3 13 30 Row4 4 14 44 Above is my table After PRESS F5 What process is running in Background ...
0
votes
1answer
40 views

How do I backup/restore database encryption key in order to restore on new server

I am currently in the process of restoring a TDE encrypted database to another instance. I have backed up master key and certificate, and have restored them to the new server fine, but I am still ...
0
votes
0answers
23 views

Import from one table in two tables where I need the auto-generated primary key in the second table

followning scenario: 3 Tables 1 Table name,street,country,bank This table needs to be imported to Table1 Address(Primary Key Autoincrement ID),name,street,country Table2 Address,bank So I need ...
0
votes
1answer
47 views

How can I reseed all identity columns?

I deleted all rows from 20 tables after disabling the constraints, triggers using the stored proc SP_MsForEachTable. Now before the import happens, I need to reseed all the identity columns back to ...
1
vote
1answer
72 views

SQL Server 2008 logging [closed]

We have a SQL server that has been hardening per government STIGs. Right now we are generating almost 10GB of Transaction log every day. (run sharepoint and some other applications). I'm trying to ...
2
votes
1answer
137 views

Find if Column Belongs to User Table

I want to compute the number of columns with not null constraint in my database. So I thought about querying the table sys.all_columns: select * from sys.all_columns The problem is that it ...
1
vote
1answer
144 views

View the order of triggers firing

We have 2 SQL Server 2008 environments with some triggers against a table containing business logic Within the 2 environments, we can see that the triggers are firing in a different order (thanks to ...
1
vote
1answer
50 views

SQLDriverConnect fails when attempting to connect to Failover_Partner

SQLDriverConnect fails when attempting to connect to Failover_Partner. Connection string being used: Driver={SQL Native Client};Failover_Partner=tcp:dby;Server=tcp:dbx; ...
0
votes
1answer
50 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
59 views

Will SQL Server 2014 not cause problems with a SQL Server 2008 DB?

I will be doing development work on a database created in SQL Server 2005 that will be moved to SQL Server 2008. I have no problems moving them; I've done it before and it's always been painless ...
2
votes
3answers
295 views

How to pull rows only from the weekends?

My table data is like this: ID Name salary date 1 a 100 1/08/2014 2 b 200 2/08/2014 . . . . 26 z 2600 26/8/2014 Now I want to return only rows from Saturday or ...
1
vote
1answer
49 views

Cursors and concurrent users

I typically avoid cursor operations like the plaque, however, I have come across my first problem where using a cursor outperforms a query. So I am forced to use it. I have created an elaborate ...
4
votes
1answer
96 views

Why is SQL Server's online indexing causing blocking?

My understanding is that online indexing acquires locks at the beginning (Preparation) and end (Final) phases. However, we see a lot of DML queries blocked during the Build phase. A sampling of the ...
0
votes
1answer
48 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 ...
0
votes
1answer
69 views

How to generate replication snapshot without locking tables

When I reinitialize subscription and generate new snapshot it locks all tables and makes the database unusable for a very long time (never waited it out). Is there anyway to do this without locking?
0
votes
0answers
43 views

Subscription fails with Incorrect syntax near '9'

In my Distributor To Subscriber History I get the following error: Command attempted: 9 (Transaction sequence number: 0x0018E94F0000207A006200000000, Command ID: 59) Error messages: ...
1
vote
3answers
106 views

How to separate Stored Procedures (i.e. all the business logic) from Client Database so that it only contains client data?

Scenario: Our Application Database (in SQL Server 2012) contains entire business logic in the Stored Procedures (SPs). Everytime we have to publish the DB to the client, it unnecessarily results in ...
5
votes
2answers
347 views

Index seek much slower with OR condition compared with separate SELECTs

Based on these questions and the answers given: SQL 2008 Server - performance loss possibly connected with a very large table Large table with historical data allocates too much of SQL Server 2008 ...
0
votes
1answer
75 views

Update primary key column - NULL issue

I want to update a column that is a primary key using this code use BITS_TEE Update DMT_TEE_DTS_Production set ABCIndicatorCode = ( select HIST.ABCIndicatorCode from ...
1
vote
1answer
89 views

Change rowguidcol property to a different column

In my SQL Server 2008 database, I have a table with two uniqueidentifier columns. CREATE TABLE MyTable ( Col1 uniqueidentifier rowguidcol not null, Col2 uniqueidentifier not null, ...
1
vote
4answers
195 views

Large table with historical data allocates too much of SQL Server 2008 Std. memory - performance loss for other databases

Based on this question and the answers given: SQL 2008 Server - performance loss possibly connected with a very large table I have discovered memory allocation problem with SQL Server 2008. ...
7
votes
6answers
1k views

Estimate projected database growth

I recently started working with SQL Server 2008 as a DBA trainee. I need calculate the size of the database but also estimate its growth over recent months and the predicted growth for the next 12 ...
1
vote
2answers
191 views

SQL 2008 Server - performance loss possibly connected with a very large table

Migrated from http://serverfault.com/questions/615129/sql-2008-server-performance-loss-possibly-connected-with-a-very-large-table We have SQL Server 2008 with 3 active databases running on it. DB1 ...
0
votes
3answers
83 views

How to display posted on date and time like1 hr ago or 30 min ago

i want to show the posted date like 1 hr ago.. or 30 min ago.. declare @date datetime ='2014-07-24 11:50:22.033'; SELECT CASE WHEN DATEPART(DD,@date)=DATEPART(DD,GETDATE()) THEN CASE WHEN ...
0
votes
3answers
62 views

Matching two rows in a single table if two specific keys have different values

I have a table called settings in that there are two columns and data like following. settings value ------- ------ depots 12 projectid 156 client ...
1
vote
2answers
64 views

How to find usage of each object in other objects from a database?

I am with the task of taking an old SQL Server database and identify all of it's objects and their relationships, because the one who made it did not bother to use any foreign key, he just made all ...
1
vote
1answer
52 views

Single row to multiple rows with column combination

I have a table like this: ╔═════╦═══════╦════╦════╦═════╦═════╦═════╦═════╦════╦════╗ ║ ZIP ║ STATE ║ F ║ C ║ F1 ║ c1 ║ f2 ║ c2 ║ f3 ║ c3 ║ ...
0
votes
2answers
67 views

How to provision the SQL Server Agent service after SQL Server Edition upgrade

I have upgraded SQL Server 2008 R2 Express to SQL Server Standard Edition. After I have upgraded it, the SQL Server Agent was stopped. I have tried to start but it fails. Only when I have changed ...
2
votes
2answers
158 views

Table with 4 million records - different size and performance in development and production

At my company we use SQL Express 2008 R2, which supports databases up to 10GB. We have 2 databases with almost the same number of rows in all tables. But, one of them is 4.5 GB in size (which is in ...
0
votes
2answers
59 views

Transfer all tables from a schema to other schema

I have two schema. Schema1 and Schema2 How would I transfer all the tables from schema1 to schema2?
1
vote
1answer
53 views

Print the execution time on messages Pane?

How I can print the execution time of each query on messages Pane? For example the Select * from tbl1 runs for 10 mins then Select * from tbl2 runs for 15mins and so on.. Select * from tbl1 Go Select ...
1
vote
1answer
54 views

set date value based on other row values

Sorry for the Header, I can't find the right way to describe what I want, possibly the reason why I can't get a solution by googling :) ... Here my problem: I've got a table with the following ...
0
votes
0answers
44 views

Track record deltas/changes on SQL Server 2008

Trying to build some sort of ETL process that copies rows from SQL Server into Elasticsearch indexing server. My ETL process should be able: Detect new rows inserted to the SQL Server table. Detect ...
0
votes
1answer
62 views

Indexes and their uses [closed]

Index improve performance in select statement, but what is the difference between this create clustered index ix_index1 on table1(col1) create clustered index ix_index2 on table1(col2) and this ...
3
votes
1answer
54 views

Centralized master data shared among other several DBs

I'm researching and investigating about all possible ways to create a master data database for my portfolio of applications. To give you a quick overview, an example will come in handy: I want to ...
1
vote
4answers
132 views

Is it ok to change from full recovery to simple recovery in Sql Server

I have an old database - a users membership/role that was setup automatically by an ASP.Net 2 application years ago: The Sql Server version currently running is: Sql Server 10.5.1617 The users ...
0
votes
1answer
55 views

How to Sum Each Enum Value in a Different Column and Don't Repeat Person's Name?

Let's say I have a table with SellerId, DateTime, ProductType to register each time a a Seller sells a product. The ProductType is from ENUM type with { 0=Phone, 1=Recharge, 2=SimCard }. Then I have a ...
4
votes
3answers
155 views

Virtual Log Files (VLFs) Fragmentation

I have a database with 160 VLFs. How do I determine whether the VLFs are fragmented? Further, how do I find the percentage of fragmentation? Another thing that I want to confirm: Are the following ...
1
vote
2answers
2k views

Adding Data to Multiple Tables Using Single Query [closed]

I want to add data to multiple tables using a single INSERT INTO query, can I do this? Please guide me and provide me syntax if this is possible.
1
vote
1answer
57 views

High Service Broker queue

My production database suffers from a large Service Broker message queue. It is around 2 million. I would like to decrease it as small as possible. I have tried dbcc ...
1
vote
1answer
52 views

Get data per Customer and per Date

How will I get the all the date even though there is no order between two dates? Sample Table OrderID | Date | CusID 33942 | 6-21-2014 | 6005 34059 | 6-20-2014 | 4003 53333 | ...
1
vote
0answers
99 views

How do I analyse DBCC Showcontig of a table? [closed]

Can somebody help me how to analyse the DBCC SHOWCONTIG output for a table. Before: Table: 'table1' (795); index ID: 0, database ID: 7 TABLE level scan performed. - Pages ...
0
votes
1answer
98 views

UPDATE not working properly with linked server

Please see a question I asked here earlier: http://stackoverflow.com/questions/24324823/update-not-working-properly-with-linked-server Dommer suggested using OPENQUERY and this does appear to resolve ...
0
votes
0answers
19 views

Check if any user uses a database? [duplicate]

I'm going to drop a database. I want to monitor if any user is still using the database for a couple of months. Besides profiler, is there a better way to monitoring activities on a database?
1
vote
2answers
48 views

Making a Database Online [closed]

I am so confused with this issue, I have vb.net application and it has a sql database . Now, I want this application to access the sql server from anywhere , because there are many clients sharing ...
1
vote
2answers
98 views

Proper Shutdown of SQL Servers in a Cluster

I was just wondering what the best approach should be for shutting down an Active/Active Cluster where both nodes need to be shutdown for disk maintenance. I was thinking of this process: Open ...
1
vote
2answers
57 views

How to get the first or last row in ordered result set, depending by column value?

I have the follwoing result set from the table PUNCHREPORT EMPLID Name PUNCHDATE PUNCHTIME DEVICETYPE .................................................................. 70 ...
4
votes
1answer
119 views

Table Data Space Used Confusion

I have a heap table with around 700k rows. The rowsize is 34 bytes: (1x BIGINT, 2x SMALLINT, 2x BIT, 4X INT, 1x SMALLDATETIME). Why does Data Space Used say this table is taking up nearly 4000000KB ...