sql-server-2005

SQL Super Search

Does anyone have a good method for searching an entire database for a given value? I have a specific string I'm looking for, it's in TableA, and it's also a FK to some other table, TableB, except I don't know which table/column that is. Assuming there's a jillion tables and I don't want to look through them all, and maybe will have to d...

Join to subquery not working?

I should be able to reference tables in the join clauses from a subquery, shouldn't I? But the following query is giving me errors saying they can't be bound: select * from call c JOIN call_task ct ON c.call_no=ct.call_no AND ct.calltask_no = (select min(ict.calltask_no) FROM call_task ict WHERE ict.call_no=c.call_no) JOIN business b O...

SqlBulkCopy into table with composite primary key

I'm trying to use SqlBulkCopy to insert new rows into my DB table by manually populating a DataTable w/in my application. This works fine for all tables except the table that has a composite primary key made up of 3 columns. Whenever I try to SqlBulkCopy anything into this table, I get the following error: Violation of PRIMARY KEY con...

Getting a comma-delimited list of PK's for duplicates of a record in SQL Server 2005?

This is an off-shoot of a previous question I had: http://stackoverflow.com/questions/1544314/a-little-fuzzy-on-getting-distinct-on-one-column This query makes a little more sense, given the data: SELECT Receipts.ReceiptID, FolderLink.ReceiptFolderID FROM dbo.tbl_ReceiptFolderLnk AS FolderLink INNER JOIN dbo.tb...

Increasing performance on a logging table in SQL Server 2005

I have a "history" table where I log each request into a Web Handler on our web site. Here is the table definition: /****** Object: Table [dbo].[HistoryRequest] Script Date: 10/09/2009 17:18:02 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[HistoryRequest]( [HistoryRequestID] [uniqueidentifier] N...

how to calculate count in sql?

I have the following table: memberid 2 2 3 4 3 ...and I want the following result: memberid count 2 2 3 1 ---Edit by gbn: do you mean 2? 4 1 I was attempting to use: SELECT MemberID, COUNT(MemberID) FROM YourTable GROUP BY MemberID ...but now I want find which record which ...

SSIS Package Config File Encryption

We have SSIS package config files that contain DB encryption passwords or PGP encryption passwords. I came to the conclusion that there is no "silver bullet" solution for encrypting SSIS package config files like with web.config files ect. Should we consider not using config files at all for SSIS packages and if so what other options d...

Retrieve the last id from the SQL Server database table

How do I get the last id created in the policy table and store it into a variable so that I can use it for another table called backupspec table. System.Data.SqlClient.SqlConnection dataConnection = new SqlConnection(); dataConnection.ConnectionString = @"Data Source=JAGMIT-PC\SQLEXPRESS;Initial Catalog=Sumoo...

pseudo concept.

i want to know about the pseudo concept in sql in detail with some examples? i would be glad if u help me out of it. thanks and regards.. ...

How to clean sys.conversation_endpoints

I have a table, a trigger on the table implemented using service broker. More than Half million records are inserted daily into the table. The asynchronous SP is used to check sveral condition by using inserted data and update other tables. It was running fine for last 1 month and the SP was get executed withing 2-3 seconds of insertion...

Searching SQL Server

I've been asked to put together a search for one of our databases. The criteria is the user types into a search box, SQL then needs to split up all the words in the search and search for each of them across multiple fields (Probably 2 or 3), it then needs to weight the results for example the result where all the words appear will be th...

how to convert data from xml file to excel sheet

1: Is there any way to covert the xml data into Excel workSheet? 2: Also from database (sql server 2005 ) to an Excel worksheet? ...

ACT Professional for Windows-Memory leak?

I have an ACT! professional for Windows V11.1, with the latest SQL service pack (SP3) and have an apparent memory leak on the server. After a restart the ACT! SQL instance (SQLSERVR) consumes almost all the available memory on the server, we have added more memory to the server (it is running under Hyper-V) but it continues to consume ...

How to Get SQL Server Database performance Information?

Are there any standard queries that can be run that will show the performance of a SQL Server 2005 database? Note: I need to know the performance of every aspect of the database. EDIT: I am looking for a way to measure the time it takes for typical queries to execute. I am then going to apply indexing to certain tables in the database ...

LINQ to SQL Cannot create database [Schema Permissions]

For some integration tests I want to use LINQ to SQL to drop/re-create the test database. I've had this working fine before, however in this project the database is split up into several schemas. When I try to run the ctx.CreateDatabase() command I'm getting this exception: The specified schema name "xyz" either does not exist or...

iterating XML data in sql server 2005

I have a storedprocedure which accepts @MissingRecordsXML NTEXT It contains XML records. Now someother developer has used a cursor to fetch rows from OPENXML and then has applied all the business rules on each row and after that each row is inserted in a table. I want to know which is the best way to foreach XML data in SQL Server.I ...

SQL datetime value

I have data formatted "2009-07-17T00:00:00-05:00" in varchar variable. How can I convert this data to datetime field in MS SQL server using query or TSQL? ...

Create XML from SQL Server 2005 data using FOR XML

I'm trying to create an Excel XML that I want to store in an XML Field in SQL Server 2005. I have gotten this far: WITH XMLNAMESPACES ( 'urn:schemas-microsoft-com:office:spreadsheet' as "s", 'urn:schemas-microsoft-com:office:office' as "o", 'urn:schemas-microsoft-com:office:excel' as "x" ) select 'Order' as "@s:Name", ( selec...

SSAS - Moving Annual Total

Environment: SQL-Server-2005, SSAS 2005 I am using the following formula to create a Moving Annual Total SUM ({[Time].CurrentMember.Lag(3):[Time].CurrentMember}, [Measures].[TRx Quantity]) The same column [Measures].[Trx Quantity] is used in other calculations and it works fine. This one, however, comes up with #Value! to indicate so...

How can I use if statement after a CTE (SQL Server 2005)

Last night I was writing a simple T-SQL program something like this DECLARE @ROLEID AS INT SELECT @ROLEID = [ROLE ID] FROM TBLROLE ;WITH CTE AS ( SELECT * FROM SOMETABLE ) IF (@ROLEID = 1) BEGIN //SOMECODE END ELSE IF(@ROLEID = 2) BEGIN //SOMECODE END ELSE BEGIN //SOMECODE END I found after compilation th...