sql-server-2005

Returning first instance of value across multiple tables (and returning associated columns)

I am looking to return the following information for each contact contained within a set of tables: Contact_id | first_Event_date | first_Event_id | event_type id123456 | 01/12/2007 | eveid123456 | table1 id456455 | 05/06/1999 | eveid456585 | table4 Where the data reflect...

StoredProcedures ... "The Request Properties cannot be supported"

Hi all, I have a problem with SQL Server 2005 and classic asp and recordsets. Whenever I modify a Table, it seems to affect all the stored procedures dependent on that table and when I call the (select) sproc, the error is: "The Request Properties cannot be supported" But when I run the sproc in query analyzer window, there are no ...

MS SQL Order BY Case

I have a query with 3 columns (for sake of the example). One is DATE and one is [Type] and one is PRODUCT. I need to order the query by DATE but also by type in terms that name like Buy, Transfer In shows up first and then Transfer Out and Sell. The order of [Type] is very important for me since there is this case where I get Sell even b...

SQL Server 2005 and 2008 in conjunction

Is it recommended to use two versions of SQL Server (2005 and 2008) for storing data of an application. We have a situation where we have an existing web application consuming SQL server 2005 as a database. Some enhancements in the application required us to solution a FILESTREAM data store. Now we have our data in SQL Server 2005 and as...

sql query multiple record insertion

how can i insert multiple records using single sql statement ...

update and return another string in a SQL function

I want to update a string and return a string in a SQL function. The update works perfectly but the returning the string is not working,when i deactivate the sp_executesql the function returns the value. why we can't execute a command and return a different value. please help me the SQL FUNCTION =========================================...

Order by table function

why error? CREATE FUNCTION [dbo].[seth] (@IdUrl BIGINT) RETURNS TABLE AS RETURN(SELECT * FROM dbo.NetGraph ORDER BY IdUrl) error Msg 1033, Level 15, State 1, Procedure seth, Line 4 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specifi...

The transaction has aborted.

I have a multithreaded C# application where each thread has it's own set of db connections. Each thread uses TransactionScope / DTC. Sometimes, I get a "The transaction has aborted" exception. It's not from a timeout since it occurs in less than 2 seconds from starting the transaction. Here's the stacktrace: at System.Transacti...

What is a fast way of joining two tables and using the first table column to "filter" the second table?

Hello! I am trying to develop a SQL Server 2005 query but I'm being unsuccessful at the moment. I trying every different approach that I know, like derived tables, sub-queries, CTE's, etc, but I couldn't solve the problem. I won't post the queries I tried here because they involve many other columns and tables, but I will try to explain ...

SQL Server Comma Separated value among columns

I want to select columns as comma-separated values by doing something like: select column1+','+column2+','+column3+','+coulmn4 from someTable except if any of the columns hold null values i have to skip that column from adding comma how to do this is SQL Server? [All columns are of type varchar so no casting needed] ...

Backing up Database AND replication configuration?

In SQLServer 2005, is it possible to migrate a database from a workstation to another and also take the Replication configuration with it? I mean, besides creating scripts. ...

Can my users inject my dynamic sql?

I'm a desktop developer writing for internal users, so I'm not worried about malicious hackers, but I would like to know if there's anything they could enter when updating a value that would execute sql on the server. The business defines their content schema and I have a CRUD application for them that doesn't have to be changed when th...

stored proc returns no results, but query does.

Hi all, I have just managed to enable full-text searching to make searching for products in my system easier. However, I am using an sp that was built by someone else and it is not returning any results for "Duty Call". In actual fact I am searching for "Call of Duty", a product in the system. If I type "Call of Duty" it does return a r...

How can I optimise this Query ?

How can I optimize this query if given the following query returns either all entries in the table or entries that match only up to current date ? btw: The Query is targeted to a Oracle Linked Server on MS Sql 2005 as an Inline function.. Do not want this to be a table value function.. ALTER function [dbo].[ftsls031nnnHades](@withExpir...

I Need Countries List in T-SQL

I have a Country table which has CountryName column. I need a ready made list in DDL to populate in the column CountryName. The table resides in SQL Server 2008. ...

How to name sql table and its category in sql server?

I have table called Services and I want to make another table that have the Categories of services ( One-to-Many ) What's the best approach i can use to naming it is it one of the following ? ServiceCategoreis ServicesCategoreis Serviecs_Categories CategoriesOfServices ...

Filter data from intermediate table with AND link

Hello community, i'have following scenario: Tables and Columns (Database Type: Microsoft Sql Server 2005): Table: Entries EntryID ... other unimportant columns Table: Attributes AttributeID Table: EntryAttributes EntryID [Releation To: Entries->EntryID] AttributeID [Releation To: Attributes->AttributeID] So, how can i sele...

SQL 2005 - Table valued function compiles ok but throws Incorrect syntax near .. when selected

This table valued function compiles ok, alter function [dbo].[ftsls031nnnHades](@withExpiredEntries smallint ) returns @t table( comno varchar(3), t$cuno varchar(6), t$cpgs varchar(6), t$dile float, t$qanp float, t$stdt varchar(10), t$tdat varchar(10), ...

need help optimizing this sql expression

hello, in my query's WHERE clause i have this code: ... where @PageID in (...subquery...) or not exists(...subquery...) ... where the subquery is the same in both cases. that is, i want @PageID to appear in the subquery only if the subquery is not empty. is there a way to use the subquery once with the same effect? thanks konstanti...

DMF and DMV in SQL Server 2008

What are Dynamic Management Functions (DMF) and Views (DMV) in SQL Server 2005/2008 ? ...