This tag is for SQL Server 2008, major build version 10.00.xxxx.

learn more… | top users | synonyms (2)

0
votes
0answers
10 views

Event 17058 - initerrlog: Could not open error log file (SQL Server)

I'm new to SQL Server and encountering an error when running sqlservr.exe (Microsoft® SQL Server® 2008 R2 SP2 - Express Edition) Error 17058, Severity: 16, State: 1. initerrlog: Could not open ...
2
votes
2answers
61 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
0answers
8 views

Is there a way to set the data source in Report Manager for whole folder rather than each report?

I have few reports under different folders in Report Manager. Is there a way to set the data source for the whole folder rather than each report individually? There is also a folder where reports ...
2
votes
1answer
62 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 ...
2
votes
1answer
25 views

Propper way to monitor SQL Server mirror status from service or job?

We have a production DB which is in a mirror configuration. It is in synchronous high safety with automatic failover configuration. Right now we monitor it using windows service which pings it. Is ...
2
votes
0answers
38 views

SQL Server restore differential after restoring full backup

Here is the situation: I had a full backup, and a differential backup. I have restored the full backup into the database. But accidentally lost that backup file. Now I would like to apply the ...
0
votes
1answer
33 views

DTS Type Mismatch at Join

I am new to ETL and VB in general and need some help resolving this issue. I have looked online and found some interesting answers but none seem to be working for me. varamt = Lookup ( ...
4
votes
1answer
32 views

Should Service Broker use SQL or Windows Authentication?

I was curious what the best practice would be, for properly setting up Service Broker in SQL Server 2008. Should I use a SQL authenticated user, or should I use a Windows NT Authenticated user based ...
6
votes
1answer
109 views

How to find the stored procedure which executed an event?

I have a problem where a certain stored procedure disappears occasionally and I need to find out which script deletes it. I found this piece of code which gives the events related to the deletion of ...
0
votes
0answers
20 views

Send trigger email when someone connects to a database

How do I set up a trigger or alert so that when anyone connects to a specific database, an email will get send with that user's login credentials?
0
votes
1answer
52 views

How to insert values through inner join

Could anybody tell me how to do insert statement with inner join. i am trying to insert ProductName,ProductCompany,ProductPrice,ProductQty in Product table and CategoryName in category Table. And ...
0
votes
0answers
24 views

Can you use SQL Server Development Edition for a website? [duplicate]

I've got a website I'm developing, and it's database driven. If I use SQL Server Development Edition as the back end, is that "legal"? I'll be the only developer using the software, but it will be ...
2
votes
1answer
19 views

Selecting closest, non expired value [duplicate]

I'm trying to select multiple rows where the value is closest to the end date but not passed, and return only those rows. Here's a sample of some data: School Code | School Year | Semester | Term | ...
0
votes
1answer
24 views

Pivot Results By Day [duplicate]

I have a table in SQL Server 2008, with mails received from a pop account. The table has the following columns: +------+----+---------+------+------+ | from | to | subject | body | date | ...
0
votes
0answers
21 views

Query to get result in Excel file [duplicate]

The following query gives me the error Incorrect syntax near 'OUTPUT'. SELECT * FROM dbo.sales ; OUTPUT USING 'Driver=Microsoft Excel Driver (*.xls); DBQ=c:\\test\\sales.xls; READONLY=0' INTO ...
3
votes
2answers
50 views

Is is possible to recover a database from the 'raw' files (.mdf and .ldf) of the old server to a new SQL Server instance on a new server?

I have a client that has POS software called Restaurant Pro Express (RPE) from www.pcamerica.com. RPE uses a SQL Server database. Their old POS server had a hardware failure, but I was able to attach ...
2
votes
2answers
48 views

Optimizing query using a WHILE statement

I'm trying to convert a view that extracts a yearly amount into something more WHILEish The query is more or less: SELECT * FROM (SELECT SUM(EmployeePaid)*2 AS Total2013 FROM TblRecords WHERE FYear ...
2
votes
0answers
29 views

Connecting to SQL Server using PHP, ODBC, and Windows authentication [migrated]

I'm trying to use PHP to connect to an ODBC data source using Windows authentication. I can connect just fine to the server in SQL Server so I know it's running. When I try to run the command ...
2
votes
1answer
38 views

Replace/upgrade mirrored server hardware

We are deploying new VMs for a mirrored database that is in high safety mode with automatic failover and also going from SQL Server 2008 to SQL Server 2008R2. Most of the documentation I've come ...
3
votes
0answers
98 views

How to manage hundreds of SQL jobs? [closed]

I work in Microsoft SQL Server database and I have to monitor and manage hundreds of SQL Jobs to see which job will execute on what day and what time. I also have to troubleshoot the failure of the ...
3
votes
2answers
95 views

Queries on database migration

I have a SQL Server 2008 database of size around 1 TB. I want to migrate it to SQL Server 2012. I have few queries: To migrate, I will take full backup of 2008 and restore it on 2012. I want to know ...
8
votes
3answers
90 views

Lots of “FETCH API_CURSOR0000…” on sp_WhoIsActive ( SQL Server 2008 R2 )

I have a strange situation. Using sp_whoisactive I can see this: Ok, with this query, I can see what is triggering ( does this word exists in english? ) it: SELECT c.session_id, c.properties, ...
3
votes
1answer
82 views

Is it possible to validate more than one parameter simultaneously into a Stored Procedure in sql?

On Microsoft SQL Server 2008 I realized a stored procedure which contains more than 20 parameters, in this SP I update or insert data into table which does not accept null values. I need to evaluate ...
-5
votes
1answer
66 views

Split after comma into separate row [duplicate]

id name books 1 dan history,physics,english 2 ron chem,social,biology 3 mon it,ece,eee I need an output as id name books 1 dan history 1 dan physics 1 dan english 2 ron chem 2 ron ...
1
vote
1answer
41 views

Missing diagram option SSMS

I would like to create a relationship between to tables. Normally and in previous versions of sql server and the management studio I would go to database diagrams and draw the relation in the diagram. ...
3
votes
2answers
42 views

Bitemporal Table with changing schema

I have to design a database covering business assumptions using MS SQL-Server 2008 R2. The current data of the tables will be exported to text files and used as input for a certain application. I ...
0
votes
3answers
69 views

Min(date) in sum case statement [closed]

I'm trying to write a statement where the settled date is less than the min(duedate) but I'm getting this error: Msg 130, Level 15, State 1, Line 32 Cannot perform an aggregate function on an ...
2
votes
1answer
47 views

How can I optimize searching a column for a sub-string in SQL Server?

I have a very basic table: CREATE TABLE [obj_local] ( [obj_id] INT NOT NULL, [value] NVARCHAR (1000) NOT NULL ); This table stores a lot of data, and I need to search ...
1
vote
1answer
49 views

Why is FORCE JOIN option slowing down query and forcing execution plan to sort prior to joining tables?

I'm linking Orders data with the Results data for those orders. Here's the SQL query for joining and selecting the ; with orders as ( select o.*, otr.*, oo.* from Order o inner join ...
-2
votes
0answers
21 views

When backup a database [closed]

If you don't have space limitations, which would backup would be the argument about when a database (how many times at week, month, etc). I estimated that my database in 5 years will be at most 10 gb. ...
0
votes
0answers
10 views

SQL Server Merge - returning error messages properly - finding record where error occured

I have a table structure like: Parent - Child 1 - Child 2 - Child 3 In two databases, one of them has some extra fields. I want to get the data(which can be huge) from one database into another ...
0
votes
2answers
65 views

Dynamic Filters in SQL server [closed]

I have problems with my dinamic filter in 'sql server'. My problem is that the filters aren't working. When I try to execute the store procedure I just get all the data without filtering. I'm new ...
0
votes
1answer
41 views

Create an AD user from a SQL Server trigger

Running SQL Server 2008 (10.0.5520) - I have a trigger that is executed when a new record is added to the security table. I would like to extend this trigger, and create an entry in the AD system with ...
0
votes
2answers
60 views

Select statements during long update

I've a table MESSAGES id (long) | attach_data (image) | ins_date | flag this table contains all messages of my application. During night, my job cleans old attach_data with query update messages ...
5
votes
0answers
61 views

Very high transactions per second

Our production server runs on average 4,000 transactions per second. In the past few days the average has jumped to 175,000 transactions per second. That is not a typo, it's 175K per sec. Looking at ...
3
votes
2answers
45 views

will table partitioning and compression help heavily used OLTP database?

We have a very big table which is over 300gb with over half billion rows in it. This table is used for audit purpose for all critical applications. A lot of inserts are happening per seconds. Due to ...
0
votes
0answers
16 views

Migrating from SQL Server 2005 (Win 2003R2) to SQL Server 2008R2 (Win 2008R2) new Server [duplicate]

I am pretty new to the DBA field and i have been assigned to migrate all of my Production database from SQL server 2005( server A) to 2008R2 (Server B) and Decommission all of those database from 2005 ...
1
vote
1answer
35 views

SQL Server restore database file access error

I am trying to restore a database from a file on a remote machine. The script I am using is as follows: RESTORE FILELISTONLY FROM disk = '\\server\path\to\file.dmp' RESTORE DATABASE MyDB FROM ...
3
votes
1answer
74 views

Problem with clustered index? Or bad indexes? (SQL Server 2008 R2)

I have this query (it was running in 2 minutes). With new indexes, it takes 40 sec: This is the execution plan: [![100% use][1]][1] [![it's not heavy][2]][2] [![not at all][3]][3] I can't ...
3
votes
2answers
214 views

Only show results greater than a certain number when summing two values together

I have a query that sums up two values in the same table and then calculates one as a percentage of the other select account_no, 100*((sum(COMMISSION/100)) / (SUM(AMOUNT/100))) from accounts etc ...
0
votes
0answers
27 views

Combine multiple same rows into one row by using Id

This is my table: ID Contact Id Ad-type Ad-Title Images_Path 1 2 Houses For Sale lands/im1.jpg 2 2 Houses For Sale lands/im2.jpg I need output like this: ...
1
vote
2answers
216 views

Why does FETCH NEXT return second row after opening cursor?

I have a cursor declaration: DECLARE idCursor CURSOR FOR SELECT DISTINCT [id], [data] FROM #tempRemaining OPEN idCursor And the statement: SELECT DISTINCT [id], [data] ...
2
votes
1answer
29 views

Hosting SQL Server and SSIS/SSRS in same VM

I have SSIS / SSRS and large number of databases currently being hosted on the same prod server (SQL1, SQL Server 2008R2). Since SQL1 already has SSRS/SSIS installed, would it be a good option to ...
0
votes
1answer
16 views

Do we have logging feature for SQL AUDIT like we have it for transaction and error logs in SQL server 2008?

Do we have logging feature for SQL AUDIT like we have it for transaction and error logs in SQL server 2008 ????
1
vote
1answer
46 views

microsoft sql server schema [closed]

From blog.sqlauthority.com: Protecting ISV database access: in custom ISV (Independent Software Vendor) applications, the database schemas are usually complex, and in the case of applications such ...
0
votes
0answers
22 views

What is the syntax to sp_recompile logon trigger?

I would like to recompile my logon trigger using sp_recompile. But I can't figure out the syntax. E.g. these don't work: sp_recompile '[Tr_Logon]' sp_recompile '[Tr_Logon]' ON ALL SERVER ;)
13
votes
1answer
1k views

Best way to write SQL Query that checks a column for non-NULL value or NULL

I have a SP with a parameter that has NULL as default value and then I want to do a query like this: SELECT ... FROM ... WHERE a.Blah = @Blah AND (a.VersionId = @VersionId OR (@VersionId IS NULL AND ...
2
votes
2answers
62 views

SQL Server : Tracking a slow running query on completion

Am trying to work on script for slow-running queries. I understand that we can get the list of slow running queries using sys.dm_exec_requests. Say, I have a query Q1 which is running very slow, say, ...
1
vote
1answer
45 views

How to update/insert/inject nodes into XML

I have an application which stores optional Site information in an XML field. Sample table: CREATE TABLE [dbo].[Sites]( [SiteID] [int] IDENTITY(1,1) NOT NULL, [SiteName] [nvarchar](80) ...
2
votes
3answers
67 views

updating the entire column with datetime values based on other values in the row

I have a very large table [server].[dbo].[MyTable] where I need the SQL statement to fill the column 'ToDateTime' (currently full of NULLs) according to the following logic: Only add a value to ...