sql-server-2005

Cannot open database "our database" requested by the login. The login failed. Login failed for user 'ADUser'

We are rolling out our first .net 4.0 entity framework application and are having an issue with security. We have it working on our alpha site inside our development environment with the following setup: SQL2005 IIS6 .NET 4.0 asp.net mvc 2 Entity Framework NTLM But when we moved it to our production environment for beta testing we ...

SQLCMD Usage in Batch file

Hi All I am Writing a Batch Script Which has to read a set of SQL Files which exists in a Folder then Execute Them Using SQLCMD utiliy. When I am Trying to execute it does not create any output file. I am not sure where I am wrong and I am not sure how to debug the script. Can someone help me out with script? @echo off FOR %F IN (C:\S...

XML type decomposition to rowset in stored proc using nodes()

I have the SP I call the following example ways (the call is not from SQL rather it is from a .net program) or -- run with a few grantees exec someproc 99999, '<grantees><grantee id="99"/><grantee id="100"/><grantee id="101"/></grantees>' -- takes about 1 sec with > 59s on xml decomp or perhaps -- run with lots of gra...

select in sql server 2005

I have a table follow: ID first end a 1 3 b 3 8 c 8 10 I want to select follow: ID first end a-c 1 10 But i can't do it. Please! help me. Thanks! ...

Retrieve current value of ARITHABORT

Hi, I'm debugging a strange behavior which seems to be related to ARITHABORT. How can I retrieve the current value of ARITHABORT for the active connection? cheers, Achim ...

Joining multiple Parent/Child records

I am doing some analysis on a Cisco ICM database looking specifically at transferred calls. Basically there is an ICRCallKey field which is a unique number generated at a peripheral gateway for each line logged in the table. I can tell when a call is transferred by looking at the ICRCallKeyParent and ICRCallKeyChild fields and seeing if...

Simple SELECT query fails

Consider the fowling structure: CREATE TABLE [tblEntityLogs] ( [EntityLogId] [int] IDENTITY(1,1) NOT NULL, [EntityCountCurrent] [float] NOT NULL, ... ) When executing the query underneath I get an empty row returned... DECLARE @N FLOAT SET @N = 666 SELECT ISNULL(tblEntityLogs.EntityCountCurrent, @N) AS EntityCountCurrent...

Tracking Microsoft SQL Server Activity

I have a very strange and complicated situation. I have data being erased from one of my SQL Server tables, and I am not sure by what application. I would like to be able to track this. As I am sure you are wondering how I could find myself in this situation, here is some background. We have 2 servers, Web and Database running IIS6 and...

Cast uniqueidentifier to binary

Hi. how can i Cast uniqueidentifier to binary in Sql? Thanks. ...

SQL Server 2005 Query to pivot data

I have a table set up like this Project Category Date Hours Proj1 test 8/2/2010 2 Proj1 test 8/3/2010 8 Proj1 test 8/4/2010 4 Proj1 test 8/5/2010 3 Proj1 test 8/6/2010 5 I want to develop a query where you can input a saturday(Week Ending) date and get a result lik...

SQL Server Index

SQL Server 2005 SP3 on Windows Server 2008 R2. I ran a server side trace, and use DTA (database engine tuning advisor) On one table DTA is suggesting me to create a nonclustered index with clustering key. I mean per DTA I need to create a composite non clustred index with explicit clustred index key as part of non clustered index. I t...

Pass a list-structure as an argument to a stored procedure

Is it possible to pass a Dictionary<String, String> (or something similar; like a key/value pair) as an argument to a stored procedure on an MS SQL 2005 server? I'm looking for a practical example. Update This question lead me to ask this one. ...

Stored procedure: pass XML as an argument and INSERT (key/value pairs)

How would you construct and pass XML as an argument to a stored procedure on an MS SQL 2005 server? And how would you INSERT the XML into a table? The data is in the form of key/value pairs: [ 0: [key, value], 1: [key, value], 2: [key, value] ] ...

Why do only 2 records appear in the MSmerge_identity_range table for each table using identity ranges when there are 4 subscribers?

When I compare the sysmergesubscriptions table there are 5 entries, 1 for the publisher and 4 for the subscribers. I then look in the MSmerge_identity_range table and only see 2 records for each table that has managged identity ranges and the subid is the publishers is from sysmergesubscriptions. Shouldn't there be 1 record for each tab...

List user-defined error messages in SQL Server 2005

Hi, I've read a lot about defining custom error messages in SQL Server (I'm using 2005) - use sp_addmessage, pick a number over 50,000, etc. But how can I query to see the custom messages that have already been defined for a database? TIA! ...

MS SQL Server 2005: What Happens If LDF-file are lost ?

If I put my MS SQL Log file on another drive and the drive crashes. What happens to my MS SQL Database, will it create a new log file or how do I correct it? ...

Help needed with sql query.

I have a table which have an integer coloumn. Let table name is Table1 and ColName is Col1. I want to add number 15 to every value in col1. what will be the sql query for this. ...

Really slow schema information queries on SQL Server 2005

I have a database with a rather large number of tables, about 3500, and an application that needs to access a table list. On a particular server this takes over 2.5 min to return. EXEC sp_tables @table_type="'TABLE'" I know there are faster ways to do that but sadly I'm not in a position to modify the application and need to find a...

How can I copy changes from one table to another, while avoiding an infinite loop, in SQL?

I have two databases, A, and B. On database A, I have a table X, with 10 columns in it. On database B, I have a table Y, with 7 columns in it. 4 of the columns from these tables match, and whenever one table updates one or more of these columns, I need the other table to update these columns. How can I do this? Replication wouldn't ...

Sql Server 2005: Today's random records

I can easily get a random record with this: SELECT * FROM MyTable ORDER BY NewId() I can easily get a record with "today's date" with this: SELECT * FROM MyTable WHERE MyDate = "2010-24-08" -- db doesn't store times But how would I combind the two? Get 1 random record... anything with today's date. If none are found...