SQL Server 2008 (major build version 10.00.xxxx). Please also tag with sql-server.

learn more… | top users | synonyms (2)

2
votes
2answers
95 views

T-SQL SELECT use multiple indexes for no reason

I have a question about indexer and execution plans in T-SQL. My database is SQL Server 2008. I have a simple three-table db schema: The InverterData table is very large and partitioned (28,880,...
2
votes
2answers
257 views

SQL Query is getting progressively slower

We are experiencing a very weird problem when making consecutive query calls. Not sure what info is important, so I will give as much info as I can. We have a webserver and database server through ...
0
votes
0answers
31 views

SQL Server 2000 Migration on Production [duplicate]

I have a couple databases on server1 and I want to put them on server2. Application is adding new data in every couple of minutes to databases on server1. I would like to not switch off application ...
-1
votes
1answer
62 views

The Database zzz is not accessible

I have a SQL Server instance which has several Database in it. I had to restart the server, after restart one of the databases would not launch and I click the + Icon besides it, it says The ...
-1
votes
1answer
58 views

Verify this TSQL to find the indexes fragmented over 50%

select OBJECT_SCHEMA_NAME(IPS.object_id) 'schema', OBJECT_NAME(IPS.object_id) as table_name,index_type_desc, round(avg_fragmentation_in_percent,2) 'avg_fragmentation_in_percent', si.name ...
0
votes
2answers
64 views

Insert Data in seconds between 30 minutes time interval [duplicate]

I want to divide my time interval from the start time to end time. The elapsed time should be divided across 30 minute time intervals so that for this input 08:05:13 12:09:49 I should get ...
1
vote
1answer
69 views

How can I get the whole execution log of stored procedure?

I know that how many times it was executed from execution_count in sys.dm_exec_procedure_stats.But how these values are Calculated? Is there any way to know how these values get calculated? I want ...
-2
votes
1answer
71 views

Backup file from SQL Server 2012 to 2008 [duplicate]

I have a backup file of SQL Server version 2012 but I want to restore that backup on SQL Server 2008. Question: Is this possible ?
4
votes
2answers
114 views

Can't get any fragmentation of index for testing in SQL Server database

I am filling my table in my SQL Server database with some data and I have partitions. I have one clustered index in the table. The problem I am facing is that I am not getting any fragmentation which ...
0
votes
1answer
46 views

Conditional loop date lookup SQL Server 2008

If I have two tables, first one is WorkTime: ID EmpNAME Hours/Day Date0 1 Mark 7 2015-12-01 2 George 8 2015-12-01 3 Jennifer 6 2015-12-03 4 Mark ...
3
votes
1answer
80 views

SQL Server 2008 - SIMPLE database log file is HUGE relative to the actual DB?

So... I'm not a SQL Server DBA but was asked to look at a customer's situation where they have a 2GB database that has a 60GB transaction log. I've read up on a whole lot of articles on the web (Aaron ...
-7
votes
2answers
186 views

difference between two rows based upon previous difference value in sql server

I have one table like below ID Value 1 5 2 6 3 4 4 3 5 7 6 6 7 8 8 9 Output like difference between rows ID Value difference 1 5 null 2 6 1 3 4 -2 4 3 ...
7
votes
2answers
191 views

Transparent Data Encryption

Are there any best practices when configuring TDE in SQL Server 2008? On SQLMag, the article "Transparent Data Encryption FAQs" says the CPU may have increased usage by up to 30%? Other than adding ...
-3
votes
1answer
260 views

Unable to connect to SQL server 2008 R2 via computer name [closed]

I wrote a program, on my computer it works correctly because SQL Server us running on my computer, but another computer in the network can't use the database. Here is the definition of the connection ...
0
votes
0answers
18 views

Shrink Database in SQL Server [duplicate]

I have 700 GB database and I want to shrink it. What are the risks of this operation and my data will be deleted during this operation ?
2
votes
1answer
24 views

Detail of all transactions on a specific row

I've a User table and It's data can be added/ updated from a User Screen. I want detail of all transactions on any row. For example, I have data in table like this Name - Age - Salary ...
-2
votes
0answers
272 views

SQL Server Management Studio Has Stopped Working [closed]

I was executing a large script and suddenly the Sql Server had crashed, after that I tried to run the SQL Server Management Studio, but was getting the mentioned error. I even tried to repair the SQL ...
5
votes
2answers
164 views

Can sp_executesql be configured / used by default?

I am looking at an application that uses highly dynamic sql queries against SQL Server. Looking at the queries that are constructed in very weird and complicated ways, but that's a different story, I ...
1
vote
0answers
33 views

Why am I getting this network error when setting up database mirroring?

I have two servers, one in the Portsmouth, NH datacenter, one in the Kansas City datacenter, same domain. Trying to set up mirroring. First, does it matter that one server has Windows 2008R2 server ...
6
votes
2answers
2k views

Is ELSE 0 implied in my COUNT CASE WHEN statement?

What's the difference between COUNT(CASE WHEN [Column A] = ____ THEN 1 END and COUNT(CASE WHEN [Column A] = ____ THEN 1 ELSE 0 END? I've been using the former and I haven't seen the difference thus ...
3
votes
1answer
43 views

Clarification on Database Replication

SQL Server 2008 I have to do database replication which is a new for me. Goal is have mirror database on servers 2 and 3. When we set up database replication in the Server 2, 3 from Server # 1, ...
0
votes
1answer
54 views

SQL Dependent Percentage

Sample data Excepted output Math Operation Sum all Period time for each EmpName as Total Employee Time Sum Similar Tasks For EmpName, divide it by Total Employee Time and multiply by 100% ...
4
votes
2answers
316 views

MSDB log file size

We have a SQL Server 2008 cluster with 60 databases. Full backup runs every night, log backup runs every 15 minutes. The MSDB database recovery model is set to simple (default). To be able to see ...
2
votes
2answers
47 views

simpler way to write if today or tomorrow is between ColA or ColB

SELECT * FROM my_table WHERE getdate() between SPRFRDTE and SPRTODTE or dateadd(DD, 1, getdate()) between SPRFRDTE and SPRTODTE is there a way to write this as if TODAY or TOMORROW is between ...
1
vote
1answer
52 views

SSIS export to flat file - how to configure all DataTypes for columns w/o manual entry?

In my OLE DB Source to Flat File Destination Data Flow, I have quite a few columns and it's excruciating to manually set each one to decimal with a scale of 4. I tried adjusting my SQL code in the ...
-8
votes
1answer
133 views

FULL OUTER JOIN much faster than UNION ALL in SSMS, but slower in Excel [closed]

I am trying to optimise a view pulled from SQL Server 2008 to Excel, and I've managed to drastically improve the performance on SSMS. Using FULL OUTER JOIN instead of UNION ALL, I've managed to ...
0
votes
2answers
372 views

SQL Job Fails - Why?

This is my log - if I run the procedure locally it will still perform as it should and generate the message, but when it is run as a SQL Job it fails. (For security I have changed the server name and ...
0
votes
0answers
12 views

List All Stored Procedures that Query Specific Table [duplicate]

I am using this syntax, and it returns no stored procedure names (however I know their are 2 stored procedures that query the table). This is SQL Server 2008 and this is my syntax: SELECT DISTINCT ...
4
votes
4answers
102 views

How do I fix an Orphaned User in Log Shipped version of a SQL Server 2008 database

Forgive my greenness.. but would appreciate some help on this... We are doing development work on an instance of SQL Server 2008 and have multiple databases on that server that are core to our ...
0
votes
1answer
33 views

SQL Server authentication failed after server promote

we recently promoted a Windows 2008R2 server to domain controller. We then found that it hosted a SQL Server 2008R2 Express database instance. If we try to login to the DB with the domain admin ...
1
vote
1answer
86 views

Sum of time spans

I have table like that Code Time Value RowNum -------- ----------------------- ----------- ------- I370902P 2015-12-04 09:00:00.000 5.0 1 I370902P 2015-12-04 09:...
1
vote
1answer
33 views

SQL Server 2008 running schema query without identifiable cause

I am analyzing the performance on login to an application and in particular making sure the database response is acceptable. In running just the simple Activity Monitor I can see that there are two ...
1
vote
0answers
138 views

SqlException (0x80131904): Cannot open database

We keep getting the error SqlException (0x80131904): Cannot open database in our environment. We are sure the connectionstring used is correct. The user has the necessary permissions in the database ...
-7
votes
1answer
49 views

Need Immediate Help To Develope T-SQL

Hi DBAs, I want to Develop a T-SQL For Fetch data from following Table. But Condition is : I want to select only those data which status has all three status. suppose for id 1 : It has Only two ...
0
votes
0answers
16 views

How to move SQL Server to a different domain [duplicate]

I am new to data base usage and I want to know a simple steps on how to move an application server to a different domain without losing any data. Right now I'm not very good with SQL but I want to ...
3
votes
0answers
33 views

Network Traffic increase with Small Result Set

I am currently executing a stored procedure that is using up a ton of network traffic when it executes. The stored proc executes multiple stored procs within itself as well as functions and ...
7
votes
1answer
424 views

Can I recover a SQL database from Standby/Read-Only without a standby file?

Is there any way to recover a SQL database from Standby/Read-Only mode if the "standby file" is missing? (I see some references calling this a TUF file in a log-shipping scenario, but in my case, it ...
1
vote
2answers
46 views

SQL Query to find Records companywise

I want a query that will display rows of those COMPANIES who are giving theft cover and key loss Having status is yes See the Sample Data below : addon status amt1 amt2 company ...
3
votes
1answer
56 views

Are database connections from an application expensive from a performance point of view?

A colleague tells me that connections to a database are expensive and could harm performance of the application. They ask me to create a procedure that calls say another 8 procedures, that way they ...
0
votes
0answers
31 views

Broken partition function/schemes

The dilemma SQL Server 2008 Enterprise 2 partition schemes using the same partition function partition function splits on date column, monthly basis maintenance script to split partition function ...
0
votes
1answer
63 views

MSSQL how do I query sql for a latest state record after latest date

I have a table with openingdays, location, state (Open, Day Closed, Shift Closed) and the actual date. I would like to know when the day is closed for the last time (state = D) and everything what ...
3
votes
1answer
186 views

SQL to Find Partial Duplicates of a Field

I have a table with a field for a member number. The table can contain records with duplicate values for this field and does. I have a SQL query that will obtain any duplicate values for this field, ...
0
votes
0answers
48 views

Rowlock hint is doing Lock escalation at table level. i dont know why.? [closed]

I want to first do select to read rows and then do some calculations and then finally update the read row. So my transaction will be in 3 steps: select the records (In this session only allow other ...
1
vote
0answers
45 views

Window function vs group by method: find value for MAX ID

I'm trying to understand the performance issue with Window function when i select value for MAX ID --Old group By method SELECT tj.MainProcedure , tj.StartTime , tj.EndTime , tj....
0
votes
0answers
33 views

Do both the sessions need to have UPDLOCK to avoid deadlocks

The benifit of UPDLOCK is that it avoids deadlock in case both sessions run the below query at the same time - The table has clustered index on ID column ----session 1 -------- begin transaction ...
0
votes
0answers
33 views

SQL Server: Update linked table times out

I have 4 linked SQL Server 2008 R2 servers in the same network, and distributed selection queries works fine. However when I try to run something like that: UPDATE [LINKED SERVER NAME].[DB NAME].[...
1
vote
1answer
70 views

Setting up SQL Server to handle queries from external domains

I am not a SQL Server admin. I have tried to google this but can't seem to use the right words to get the right info and they all talk about remote connections to a SQL Server in terms of admin and ...
3
votes
1answer
129 views

Determine Which Parameters Passed Into Stored Procedure

Is there a way to determine (from within a stored procedure) which parameters were passed into a stored procedure (vs. those which just took the default value)?
16
votes
2answers
3k views

Why does SQL Injection not happen on this query inside a stored procedure?

I made the following stored procedure: ALTER PROCEDURE usp_actorBirthdays (@nameString nvarchar(100), @actorgender nvarchar(100)) AS SELECT ActorDOB, ActorName FROM tblActor WHERE ActorName LIKE '%' ...
1
vote
1answer
136 views

How to get SQL Server CPU and Memory read and write usage within two weeks?

Is there any a quick way or quick script on how to get the CPU and Memory usage within a time range (at least two weeks)? I did my research earlier and it seems that the procedures available seems ...