sql-server-2005

Truncating a table referenced by a foreign key

Hey, We have two tables in a SQL Server 2005 database, A and B.There is a service which truncates table A every day. Recently, a foreign key constraint was added to table B, referencing table A. As a result, it isn't possible truncating table A anymore, even if table B is empty. Is there any workaround to get the same result as truncat...

SQL Server 2005 high memory usage and performance problems

Hi there guys. I have this ASP.NET/SQLServer2005 website running on a production server (Win2003, QuadCore, 4GB). The site runs smoothly normally, but after 2-3 weeks I notice a slow performance on the site (especifically in one particular page). Also I notice that the SQL Server process is using like 2GBs of RAM. So I restart the serv...

CTE and last known date processing

Input @StartDate = '01/25/2010' @EndDate = '02/06/2010' I have 2 CTEs in a stored procedure as follows: with CTE_A as ( [gives output A..Shown below] ), with CTE_B as ( Here, I want to check if @StartDate is NOT in output A then replace it with the last known date. In this case, since @startdate is less than any date in output A...

Cannot render images locally with Sql Server 2005 Report Services SOAP service calls

I am trying to render images from SSRS 2005 via the SOAP call. When the reports service is installed on the same server as my website, the images generated do not render in the page. However, when I connect to the reporting service URL from the same web code on a separate machine the images render just fine. Is there a dependency that...

How do I use BCP or Sql Server Management Studio to get BLOB data out of Sql Server?

I'm sorry if this question has been asked already, but I couldn't find it anywhere. I have a table that stores files as BLOBS. The column that holds the file is an image datatype. I would like to be able to extract the binary data out of the column and turn it in to an actual file. I would ideally like to be able to do this with BCP o...

How to make the process quicker?

We build a system that handling the billing analyse and what it does it just have a raw bill from vendor and process to "common" table and this is using SQL Server 2005 Integration Services. The process as follow: The Integration process is running locally on the same server. The process is reading the file and copy the exact data int...

Scheduled export of database structure (table, view, sp) to file

I'm using SQL 2005. I can right click on a database and create scripts for the database that will recreate the structure (tables, views, stored procedures) elsewhere. Or just as a backup, version, etc. But, is there a way I can schedule it to do this? And output to a folder I choose? I really appreciate the help. Don ...

Problem in SQL Server 2005 using ASP.Net

I created one ASP.Net project using SQL Server database as back end. I shows the following error. How to solve this? ===============Coding Imports System.Data.SqlClient Partial Class Default2 Inherits System.Web.UI.Page Dim myConnection As SqlConnection Dim myCommand As SqlCommand Dim ra As Integer Protected S...

SQL Server 2005

i created one ASP.Net project using SQL Server 2005 .I successfully inserted .But i dont know to view the table.Please tell me ...

How to configure replication? - This database is not enabled for publication.

Hi, I'm trying to configure repication on SQL Server 2005. I can done it using wizard. But when I'm trying to run generated scripts by this wizard the error message appears: Msg 14013, Level 16, State 1, Procedure sp_MSrepl_addpublication, Line 159 This database is not enabled for publication. Msg 18757, Level 16, State 1, Procedure sp...

Storing a pre-processed varchar column in the database along with the original one

Hi all, I have a big table with names and surnames. People search this database via a Web interface. PHP code queries the table with LOWER(@name) = LOWER(name). In order to make the search faster, I want to make a derived column in the table named lower_name and always LOWER() the names before storing. But when it comes to send the resu...

How to get star query optimization in SQL Server 2005

I have a star schema but SQL Server 2005 always uses the clustered indexes to access a table. What parameters do I have to set to enable this optimization. According to http://blogs.msdn.com/sqlqueryprocessing/archive/2007/04/09/how-to-check-whether-the-final-query-plan-is-optimized-for-star-join.aspx and the DWH datasheet of SQL Serve...

How do I set order priority in full text search (Sql Server)

I have simple tbl_posts table with three columns (id, name, content) I created fulltext index for name and content columns. When I query it like: SELECT * FROM dbo.tbl_posts WHERE FREETEXT ( *, 'search word' ) I want that the order for results will be ordered first by rank in column name and then my content ...

Best way to correct garbled data caused by false encoding

Hi all, I have a set of data that contains garbled text fields because of encoding errors during many import/exports from one database to another. Most of the errors were caused by converting UTF-8 to ISO-8859-1. Strangely enough, the errors are not consistent: the word 'München' appears as 'München' in some place and also as 'MÃœnchen...

How to delete rows from tables which is referenced each other?

I want to do this: delete from table1 a,table2 b, table3 c where a.col1 = b.col1 and b.col2 = c.col2 and a.co3 <> 8001; But its giving me an error. ...

SQL Server: Drop Table with FK

On table "A" depend about 30 other tables via FK to "A.Id". For integration testing I have to drop the table and recreate it to create a defined state. Because of the dependent objects their seem to be no way to delete and recreate the table. The error message is: Could not drop object 'dbo.A' because it is referenced by a FOREI...

What authentication credentials are required for Sql Report Services and a XML data source in Lotus Notes?

We have a Lotus Notes web service that generates an XML response. In our development environment on Visual Studio we can access the data source and run the report without issue. When we run the report from SQL Server we get the following error: An error has occurred during report processing. Query execution failed for data set ...

Copy a subset of xml from one column to another on sql server

I have a table (on sqlserver05) with an xml column. The format of the column is similar to this: <doc> <field name="a">foo</field> <field name="b">bar</field> <field name="c">fizz</field> <field name="d">buzz</field> </doc> I would like to copy a subset of that xml to a new xml column, for instance: <doc> <field name="...

Getting a count of each product for each ID

Table1 ID product 001 LG 001 Sony 001 LG 001 LG 001 Sony 001 BPL 001 BPL 001 Samsung 002 LG 002 BPL 002 LG ..., I want to take each product count for each personid. Expected Output ID BPL LG Samsung Sony 001 2 3 1 2 002 1 1 0 0 .., How to make a query of taking each product count for each personid. Need SQL Query Help. ...

Clear DB Log File in SQL Server

Hi everyone, I am looking for a tsql or query which will clear the transaction log file/ Thanks in advance. ...