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

learn more… | top users | synonyms (2)

5
votes
1answer
182 views

How to index for inequality queries?

I have query that is excluding data based on the value of a float column select * from My_Table where my_Float_column != 0 and my_Float_column is not null I don't want to index a float type if I ...
0
votes
3answers
44 views

Is it possible to make an Update query right after Insert returned new Id's

I am using MS Sql Server 2008R2. For example I need to insert many rows inside TableA and I want to make an Update another TableB with newly inserted Ids from TableA. Is it possible to do in one SQL ...
1
vote
2answers
38 views

Excluding Null Values

In my syntax why does the NOT IN statement not exclude NULL values? To me, if NULL does not exist in #GoodAnswers it should return the dv Below is syntax, can someone help explain this to me? ...
2
votes
2answers
142 views

Using DateTime Variable In Where Clause

I am trying to pull all data where a sale date is >= to a certain datetime. When I execute my query I get an error of: Msg 241, Level 16, State 1, Line 15 Conversion failed when converting date ...
0
votes
1answer
22 views

Accepted Values Stored in Variable

I am trying to write a re-usable query and this is pseudo-code of what I am after. Is this possible to do in Sql Server 2008 or do I just need to write a different stored procedure for each ...
1
vote
2answers
363 views

Re-Usable Query

I have 3 tables with the exact same DDL (I know that is a horrid set-up), but each one has a different values for a field. I am hoping to be able to have a way to write ONE query for all 3 selects as ...
1
vote
2answers
38 views

Insufficient disk space in Filegroup

One of my jobs is failing and it shows below message. Error: Could not allocate a new page for database 'Reporting' because of insufficient disk space in Filegroup ‘PRIMARY’. Create the necessary ...
0
votes
1answer
34 views

Restoring multiple snapshots with SQL Server 2008

I noticed I cannot have multiple snapshots of a SQL Server database and then restore from one of them (without I believe, deleting all but the one I want to restore). Is there a way to keep multiple ...
-3
votes
1answer
48 views

SQL Server 2008 R2 - Rebuild Log

I'm trying to rebuild a log file for my database. I want to know if what is happening is normal. This is what I'm doing: use master ALTER DATABASE my_db SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER ...
2
votes
2answers
90 views

SSMS for 2008r2 job activity monitor works…SSMS for 2016 rc1 error message

Wanting to use the latest and greatest, I downloaded the SSMS 2016 rc1 (and have downloaded the previous previews, liking what I see) and I have a situation that is similar to How to resolve error &...
1
vote
2answers
106 views

SQL Query Optimization

My SQL Server version is Microsoft SQL Server 2008 R2 (SP1) - 10.50.2550.0 (X64) Jun 11 2012 16:41:53 and the query below just runs without producing an error or updating. The table [dbo].[...
1
vote
2answers
80 views

Database connectivity issue in SSIS

I have created a Connection manager in my SSIS project for database connectivity.I choose SQLClient Data Provider and select SQL server authentication mode for login.Test connection succeeded. In ...
9
votes
1answer
110 views

Why is the MSDB database TRUSTWORTHY?

The TRUSTWORTHY setting can be rather dangerous if you aren't careful and except for specific circumstances the recommendation is to keep it turned off. However by default the MSDB database has ...
1
vote
2answers
115 views

Must Declare Scalar Variable Error

My syntax keeps giving me the below error, which is blowing my mind as I think (and please kindly correct me if I am incorrect), I have declared and set this variable above. Msg 137, Level 15, ...
2
votes
3answers
134 views

Update a column for every row of a large table to a unique value in a set range

We have a SQL Server table with over 3 million rows in it. Each row represents a product. These products are provided by about 500 suppliers, and are updated each night via a file from each supplier. ...
6
votes
1answer
455 views

SQL Server Left Join strange NULL check

I've just been going through some old stored procedures, doing some optimizations and stumbled across this oddity: SELECT ISNULL(bt.BusinessTypeID, 0) AS BusinessTypeID FROM BusinessType bt LEFT JOIN ...
1
vote
1answer
46 views

Hypothetical: Security Intrusion

Had a random thought I was curious about. In the case of a security breach where a user gains access to the DB server through legitimate credentials (social engineering, phishing, fired employee, etc)...
2
votes
2answers
51 views

Show Query Results Vertical

I am wanting to show these results vertical as opposed to the default horizontal. My desired output is like this Passed w/ notes 26 Passed w/o notes 28 Passed w/ notes 52 ...
1
vote
0answers
24 views

Connection to database causes SSPI context error

I have migrated a SQL server from another server box that was decommissioned. They have the same name and also same IP address. However, when I connect to the server from an application using trusted ...
0
votes
1answer
14 views

Catalog of LinkedServer2 from Server1 shows databases on Server1

I'm on Server1 and set up a linked server to LinkedServer2, but the catalog shows the databases on Server1! I am sure I've done something bone-headed or am overlooking something horrendously obvious, ...
4
votes
1answer
134 views

Query All Databases Listed In Table

I have been using a cursor to get my results, but it is taking an extended period of time to return my result set. I am hoping to find a way to QUICKLY get the results returned (if at all possible). ...
3
votes
0answers
108 views

Read/Write Deadlock on Ms-Sql Server

We are facing deadlocks when store procedure is concurrently executed. We are using Microsoft SQL Server 2008 R2, concurrent execution is done with java executing multiple request of sp. I have ...
0
votes
1answer
68 views

Sql Server log: is 'Backup|Log was backed up' the same as 'BackupDatabase: Log files done'?

One transaction log file is growing and growing for a couple of days and I can't find out why. Now I figured out that either the way the activities are stored in the sql logfile OR the behaviour of ...
1
vote
0answers
25 views

Compare Strings After Character

I need to check email addresses against an internal known bad domain database. My internal database has domains in the form of myfreepaysite.com just no @ sign. I have been using this syntax to ...
1
vote
1answer
71 views

Hide Schemas and Tables

I have the following structure: Views dbo.vSales Sec.vSales Tables dbo.Security Sec.Products Sec.Countries Sec.Users I have 2 groups accessing my Database: Administrators Standard_User ...
1
vote
1answer
57 views

Why is deadlock alert not working?

I created a deadlock alert including notification to an operator like this: EXEC msdb.dbo.sp_add_alert @name=N'1205 Deadlock', @message_id=1205, @severity=0, @enabled=1, ...
0
votes
0answers
15 views

Can connect to the local server default instance with the servername but not via other means

I have noticed that I cannot connect to the default (and the only) instance of a production server (SQL Server 2008 R2) by specifying [single dot]., (local) or 127.0.0.1 but can by specifying the name ...
0
votes
1answer
34 views

Sql Server Security Scenario

I need some advice/help... I need to implement database security in some Databases but I don't know how to do that with this given scenario... Using LDAP Auth We have Table1 In Table1 one we have ...
0
votes
0answers
40 views

Search All Views On A Database

We have about 800 views on a SQL Server 2000 database, about once a week I run a procedure to give me information so I can see which stores have LIKE '%Camo%' in there inventory so I know who to send ...
1
vote
0answers
58 views

Why is SQL Profiler showing empty for database name and database id?

I have some code that uses Entity Framework to call a stored procedure in SQL Server. If I run SQL Profiler and filter by the database it is calling, I can see that the profiler correctly shows the ...
1
vote
0answers
64 views

“The schema script could not be propagated to the subscriber” error has SQL code instead of file name

This type of error is unfortunately not uncommon. One report of many is this one on Stack Overflow: http://stackoverflow.com/questions/11360331/sql-server-merge-replication-error-the-schema-script-xxx-...
0
votes
2answers
90 views

Linked Server Error on SQL Agent Job

I get the below error from a SQL Server Agent Job. However, if I run the query in the job manually it works fine. Why is this? Is it just SQL Agent that requires MSDTC? I don't believe it is ...
6
votes
1answer
247 views

SQL Server 2008R2 Alias not working

I have an interesting situation here. We're basically trying to migrate some SQL Server infrastructure to new hardware, and one of the boxes (single-instance, 2-node cluster) is running 2008R2. The ...
0
votes
3answers
25 views

How to insert/combine values from multiple tables?

I have multiple tables (12 for each month) that have 3 columns each ("code", "test_name", "value") Example: January code | test_name | value 0001 name1 17 0002 name2 45 0005 ...
1
vote
1answer
71 views

TSQL Script Execution Through Power shell, Special Characters Rendering Problem

We have a simple T-SQL script file (.sql), which we execute through Powershell. Everything works fine, except the script portion, where we are using some special characters as string (example: 'ô' ). ...
1
vote
2answers
44 views

Can a table column be written to treat two different values as the same value?

The title is a bit generic, but the specific issue is that the United Kingdom of Great Britain and Northern Ireland has two commonly used 2-character codes. ISO 3166-1 specifies the code GB as the ...
3
votes
1answer
132 views

Export/import data from Excel into a table with queries

I'm a newbie interested in learning and implementing things I learn. I've been working on SQL Server 2014 these days and I'm loving it. I've come across some scenario's where I would have an Excel ...
2
votes
1answer
94 views

Secondary log shipped DB becoming suspect after restore of a transaction log

The Configuration Primary DB SQL Server 2008 R2 SP3 Web Edition running in windows Server 2012 R2 x64 on a local RAID 10 SAS 10k disk array co-located in an enterprise grade datacentre Secondary DB ...
4
votes
2answers
56 views

Query to get queue position for each group

I have a queue table with the following sample data: id company location 1 acme new york 2 acme philadelphia 3 genco st.louis 4 genco san diego 5 genco san francisco 6 acme ...
1
vote
2answers
67 views

Why could query performance improve enormous after db restore on new server with worse hardware?

A asp.net page doing very slow to load a list from SQL Server has increased it's performance very much after the whole database has been restored on a new SQL Server. The asp.net app has moved from ...
0
votes
2answers
64 views

What is the minimum privilege required to create a full text index?

I just created a full text catalog on my database. I now have a developer who needs the ability to create full text indexes on the tables in this database. The suggestion given in a previous ...
0
votes
1answer
123 views

Unable to login to SQL Server using SSMS and SQL agent failing

I have SQL Server 2008 R2 ENT insalled on Windows server 2008 R2 ENT. I am unable to login to SQL Server locally after the installation. Getting below error: Connection handshake failed. An OS ...
3
votes
3answers
352 views

How to select distinct TOP but group by column

I have a result set of 500 rows, but this are for 100 invoice. I need only the top 10 of the last invoices. I found something like similar: How to select top 10 records from each category Sample ...
0
votes
1answer
45 views

Create a temp table that consolidates start and end dates plus generates a uniqueid for each consolidated record

Hey Microsoft SQL Gurus I need your help, please. This is my first post, and I have a table called projecthistory, it’s actually a view so I could take advantage of the Rank()function to get a unique ...
1
vote
2answers
43 views

Need to sum a field in a row with same it and result needs to be cumulative in a field

This is my SQL Server 2008 R2 table: ID Amount date_time 001 9.00 01/01/2015 01:01:00 001 20.00 01/02/2015 01:02:00 001 20.00 01/02/2015 01:03:00 002 20.00 01/01/2015 01:01:00 002 20.00 ...
0
votes
0answers
18 views

How to find difference in usage date based on results

I have a ticket details table that stores the information of transactions. Here is an example of the table data: Ticket_Number Detail_type_ID Description Date_Created TotalAmount Barcode ...
3
votes
3answers
106 views

Improve Restore Speed

I have a ~3GB backup file from our QA database, and a daily diff (~500MB). For data complexity reasons, some of our developers like to use regular backups from this database, and so we have a process ...
2
votes
1answer
129 views

Intermittent errors sending email from SQL Server Database Mail

I've been seeing some SMTP errors in my database mail logs. So I have a set up a test SQL Agent job that runs every ten minutes (it's only action is to SELECT NULL). It is set to send email ...
-1
votes
1answer
130 views

How to fix invalid length in all tables of MS SQL Server 2008 (R2) database

Task is simple: I want to export all SQL Server database tables using SQL Server Management Studio 2008 R2 to MySQL (or any other format that MySQL can take, e.g Excel, CSV). I have tried the ...
1
vote
1answer
31 views

Permissions to execute a procedure on database a that reads a table on database b

A user in database a has execute permission on a stored procedurte in database a, that stored procedure reads table 1 in database b however when the user executes that procedure they get the following ...