sql-server

SQL Express under IIS 7.5

I´m developing a web service that access a SQL Express database, it works very well in the Visual Studio host but when i deploy it to IIS 7.5 i get this exception. Please help me. Stack Trace: System.Data.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Failed to generate a user instanc...

sql server: looking for table usage through out database...

How would I figure out what type of sql code such as procs, functions, views etc. are interacting with my table called TABLE1 through out a given database. Sample code would be very helpful for me. thanks ...

Correct Way to Get Date Between Dates In SQL Server

I have a table in SQL server which has a DATETIME field called Date_Printed. I am trying to get all records in the table which lie between a specified date range. Currently I am using the following SQL DECLARE @StartDate DATETIME DECLARE @EndDate DATETIME SET @StartDate = '2010-01-01' SET @EndDate = '2010-06-18 12:59:59 PM' SELECT ...

Help with t-sql query

Based on the following table id Title Date Metadata ------------------------------------ 1 A 08/01/2010 M1 1 A 10/05/2010 M2 1 A 03/15/2011 M3 2 B 09/20/2010 M1 2 B 01/15/2011 M2 3 C 12/15/2010 M1 Input variables will be start and end date. S...

how do i do an insert with DATETIME now inside of SQL server mgmt studio

i have a website that does inserts into this table below. I need to do some manual inserts but i wasn't sure how do pass in the equivalent of DateTime.Now in C#. I am running this below from the query editor in sql server mgmt studio. Is there anyway to pass in the current date time in this query below. INSERT INTO [Business] ...

Execute stored procedure for each record in table

I have two tables that need to be updated, Master and Identifiers: Master --MasterID (PK) --ModifiedDate --ModifiedBy Identifiers --IdentifierID --MasterID (FK to Master) --Identifier --IdentifierType --ModifiedDate --ModifiedBy The Master table's sole reason for existence is to tie different Identifiers to a single person. I receive...

How do capture the result set from RESTORE FILELISTONLY FROM DISK... so I can query it?

How do I capture the output from the following SQL statement so I can query the resultset?: RESTORE FILELISTONLY FROM DISK = N''D:\Restores\MyBackup.BAK'' WITH NOUNLOAD, FILE = 1 Do I need to create a temporary table and then do something like?: INSERT #tmp EXEC ('RESTORE FILELISTONLY FROM DISK = N''D:\Restores\KevsP...

String or Binary DAta would be truncated on Delete

I'm trying to delete a couple of rows USING SQL Server management studio, for 2 rows only i get the message No rows were deleted A problem occurred attempting to delete row #X Error Source: .Net SqlClient Data Provider Error Message: String or binary data would be truncated The Statement has been terminated Correct the errors and ...

Use a Select Statement within a wildcard where clause

Working in MS SQL 2005 and I want to use a select statement within a wildcard where clause like so: SELECT text FROM table_1 WHERE ID LIKE '%SELECT ID FROM table_2%' I'm looking for product ids within a large body of text that is held in a DB. The SELECT statement in the wildcard clause will return 50+ rows. The statement above is o...

SQL Server 2008 Dynamic Query using CTE

I am trying to write a Dynamic Query which uses a CTE. But I am facing problems - see below This is a simplified case declare @DynSql varchar(max)=''; declare @cnt as integer; with months as ( select CAST('07/01/2010' as DATE) stdt UNION ALL SELECT DATEADD(MONTH,1,STDT) FROM months WHERE DATEADD(MONTH,1,STDT)<CAST('06/30/2011' AS DATE) ...

Unable to retrieve more than 8 bytes from a text field in sql server via Delphi ADO

Delphi 7 SQLSERVER 2000 I am having a problem with a legacy application that I am unable to recompile, because when i do I lose the ability to retrieve documents from a text field they are stored in and write to disk, I only get the first 8 bytes. I have a much larger application, but a really simple app is recreating the issue. Code ...

t-sql select query

Based on the following table Title Jul-10 Aug-10 Sep-10 Oct-10 Nov-10 Dec-10 Jan-11 Feb-11 Mar-11 Apr-11 May-11 Jun-11 -------------------------------------------------------------------------------------------- A Null M1 Null M2 Null Null Null Null M3 Null Null Null B Null M1 Null N...

SQL Server and TransactionScope (with MSDTC): Sporadically can't get connection

I've written some tests for .net code that invokes calls to my SQL Server. It appears that using System.Transactions is an excellent choice for rolling back any modifications to the database that result. I'm aware that some purists would suggest that I might want to mock the database, but I'm not going down that road; this is not stric...

Error 14274 - Can't delete & then re-add job

I'm trying to create a rather simple script for dealing with SQL Server Agent jobs. It performs 2 tasks: 1) If a given job exists, delete it 2) Create the job (Due to business requirements I can't modify an existing job, the script must delete & re-create it.) Running the script the first time works fine (creates the job). Running a...

Is there a task manager of sorts for SQL Server 2008 and on?

Is there a task manager of sorts for SQL Server 2008 and on? A way to see what SQL server is doing, kill runaway queries, etc... ...

t-sql string & table column manipulation

DETAILS table has following columns Title First Second Third Fourth Fifth ------------------------------------------ A null null null null null input variable -------------- @columns = 'Title, Third, Fourth' I want to generate ouput as @allcolumns = 'Title, Third, Fourth, First, Second, Fifth' Variable @allco...

T-Sql Error Handling and Logging

Hi I am trying to maximize the benefits from an experience. Also I usually use Enterprise library logging block, I log errors and a portion of statistical information into the database, because it is centralized place to track errors, if database logging failed, Normally it goes to Event Log. Tracing messages should go into file: W...

What permissions should be granted to the remote user to do anything with "the database" and no other?

What permissions should be granted to the remote user to do anything with the database "123" in SQL Server 2005 Express using SQL Server Management Studio Express such that the remote user cannot do anything to any other database? I would also like that the remote user cannot see the other databases. That is "123" is for the user login...

How to reverse a field in SQL Server 2008

How to reverse a field in SQL Server 2008 ...

Entity Framework: Column must be mapped although it does have a default value?

Hi, I am trying to create an Entity Framework 4 model based on a legacy SQL server 2008 database. Since the model is going to be published in a web service, I need to omit an integer column called NewsletterSubscribed from one of the model's entities. After removing the column in the EF designer I got the following compilation error: ...