sql-server

Restrictions on a Log Shipped database

In SQL 2005, what are the things that you should not do to a database that has Log Shipping enabled (and that runs under the Full Recovery Model)? I gather that scheduling additional Transaction Log backups to a different location will break the log shipping (because the full log chain is no longer reaching the secondary server). I al...

Programming decision java or .Net, db or no db

Hi I am stuck while making a programming decision, I am a .Net developer, I am currently building an application for my client that receives data from a third party application, it has to then perform operations on the values and send it to a webservice/servlet which then displays data to a webpage, The catch here is that the data bein...

ADO.NET calling T-SQL Stored Procedure causes a SqlTimeoutException

I have a T-SQL stored procedure with the signature CREATE PROCEDURE MyProc @recordCount INT OUTPUT @param1 INT ... When executed directly in Sql Server the procedure runs in under 5 seconds, returning a few result sets amounting to about 100 rows in total. Calling this procedure using the ADO.NET SqlDataAdapter.Fill method to populat...

"Lost" SQL server database

This is a really strange one. I am using SQL Server Express 2005, and have the following connection string (in a DotNetNuke web.config): Data Source=ELECTROMORPH\S15304561;Integrated Security=True;User Instance=True Note that there is no AttachDbFilename parameter - so I'm not sure how SQL server even knows what to connect to. But it...

Finding out which locks that are acquired in a query on SQL Server?

I have a SQL statement from my application. I'd like to know which locks that statement acquires; how can I do that with SQL server? The statement has been involved in a deadlock, which I'm trying to analyze; I cannot reproduce the deadlock. I'm running on MS SQL Server 2005. ...

SQL Server 2008 Reporting Service 2008 the page margins not set while exporting to Excel

Hi, While using new SQL Server 2008 Reporting Service 2008 the page margins that I specify in Report Properties > Page Setup do not seem to flow through to Excel when exported? They always seem to be set to Top & Bottom: 2.5cm, Left & Right: 1.9cm, no matter what I set them to in the report. This was working perfect in 2005 version. An...

ms sql server; varchar(MAX) vs TEXT

I just read that VARCHAR(MAX) (which can store, what, close to 2GB of char data?) is the recommended replacement for TEXT columns in 2005 and newer. My question is, if I want to search inside this column for any string ( ... WHERE COL1 LIKE '%search string%' ...) is it quicker to search a VARCHAR(MAX) using the LIKE clause, or use the TE...

How do I disable a full-Text Search on a column in sql server?

I'm trying to convert a column from ntext to nvarchar(MAX), but it seems there is a Full-Text search enabled on it. Alter table <table> alter column <column> nvarchar Then i'm going to force the text into rows update <table> set <column> = <column> +'' where <column> is not null Finally I'll need to enable the full text search...

Will there be performance issues when I (mis-)use an indexed database table as a fulltext search index?

At work we had a discussion about adding a fulltext search engine to our product. One proposal was to use a MSSQL database table as a fulltext search index, like this: Keyword Document ------------------ This Doc1 Is Doc1 A Doc1 Test Doc1 And Doc2 This Doc2 Too Doc2 A search would get all rows conta...

SQL: search for a string in every varchar column in a database

I have a database where a misspelled string appears in various places in different tables. Is there a SQL query that I can use to search for this string in every possible varchar/text column in the database? I was thinking of trying to use the information_schema views somehow to create dynamic queries, but I'm not sure if that will wor...

SQL Dynamic DatePart when using DateDiff

Is there a way to pass the DatePart parameter of DateDiff as a variable? So that I can write code that is similar to this? DECLARE @datePart VARCHAR(2) DECLARE @dateParameter INT SELECT @datePart = 'dd' SELECT @dateParameter = 28 SELECT * FROM MyTable WHERE DATEDIFF(@datePart, MyTable.MyDate, GETDATE()) < @dateParameter The only ...

Sql Server 2005 SSIS/Agent - Query status of a job

Is there a way to query the current status (executing, idle, etc) and the last result (successfull, failed, etc), and the last run time for a specific job name? The end result I am looking for is being able to display this information in an internal web application for various SSIS packages. ...

SQL statement for evaluating multiple related tables

I have a Projects table, which lists the client info. Then I have four related jobs tables, for jobs within that project - Roofing, Siding, Gutters and Misc. The four tables have a projectID field to link them to the Projects table, and they all have a 'status' field. A project can have any combination of jobs. I want to be able to sele...

How do I change my asp.net membership database from express to standard sql?

I am building an ASP.NET 3.5 (C#) application and I plan to use the membership and roles security. I want to set this up on my SQL Server 2008 standard edition and not the default express setting. How would I go about this? ...

How to Add Nonrecorded Time Gab in recorded timeGap? How to create tihs method?

CREATE procedure sp_ActivityFrequencyOneUserGraph ( @date1 nvarchar(100) , @date2 nvarchar(100), @customerID int, @user int, @type nvarchar(50) ) as select Count(Page) as VisitingCount,[Time] from ( SELECT Page,Date,[user], ...

SQL equivalent of MS Access Partition function

I use Partition function lot for Report in MS Access 2003. I need equivalent of this function for MS SQL. Here is link about Partition function http://office.microsoft.com/en-us/access/HA012288921033.aspx (registration required) Thanks ...

Log to XML column using log4net

Is it possible to log to an XML column in SQL Server using the AdoNetAppender in log4net? I know that I can treat the column as a string and log that way through: <parameter> <parameterName value="@details" /> <dbType value="String" /> <size value="4000" /> <layout type="log4net.Layout.PatternLayout"> <conversionPa...

Can a trigger be forced to run in a separate context than the user in SQL Server 2000?

Let's say I have a SQL Server 2000 table, any name will do, it's irrelevant for this topic. On this table I have a trigger that runs after update or insert. The user is able to insert and update the table on which the trigger is attached, but not on other tables that the trigger targets. If the user modifies data in the original table...

Does a foreign key automatically create an index?

MS SQL Server 2000 I feel silly for asking this question, but I've been told that if I foreign key two tables, that SQL Server will create something akin to an index in the child table. I have a hard time believing this to be true, but can't find much out there related specifically to this. My real reason for asking this is because we...

VARCHAR collation versus VARBINARY ordering in SQL Server 2000

I need to do some in-memory merging in C# of two sorted streams of strings coming from one or more SQL Server 2000 databases into a single sorted stream. These streams of data can be huge, so I don't want to pull both streams into memory. Instead, I need to keep one item at a time from each stream in memory and at each step, compare the ...