sql-server-2005

how to show sales summary in rdlc from four sql table using sql

hello guys, I am having bad times to generate a rdlc report to show report in predefined format given by my client. Client given format As you can notice RED background is my problem area, Item "A" price has been changed thrice. And accordingly their sales, breakages and refund quantity is shown. I have 4 tables Products, SalesLog, Br...

Optional parameter in SQL server

Hi, I have a user defined function which is used in many stored procedures which will return me some value. If it possible for me to add a new optional parameter to the same. If I don't pass any value it should be null and if I pass some value it should take it. I don't want to go and change all the stored procedures to do so. Example...

transition from developmental stage to deployment stage

Hi...I've created a web enabled database using SQL Server 2005 to store the data in the DB(back-end) and MS Visual Studio 2008 web forms to access the data(front end).... I've sucessfully simulated the process of accessing the data from SQL Server stored in my friend's laptop through my laptop using SQL SERVER AUTHENTICATION in MS VISUA...

Title: Multipart identifier s.Company_id could not be bound

I am getting the following error while executing the query . Please help Multipart identifier s.Company_id could not be bound INSERT INTO Company_Item_Company_List ( Company_id, Company_item_id, client_id, last_modified_timestamp, last_modified_user_id ) SELECT dcsl.distribution_center_id, sisl.Compan...

Searching Technique in SQL (Like,Contain)

I want to compare and select a field from DB using Like keyword or any other technique. My query is the following: SELECT * FROM Test WHERE name LIKE '%xxxxxx_Ramakrishnan_zzzzz%'; but my fields only contain 'Ramakrishnan' My Input string contain some extra character xxxxxx_Ramakrishnan_zzzzz I want the SQL query for this. Can any ...

Insert Trigger does not work on bulk insert; trigger is working with cursor

On bulk insert, Insert trigger only works for the first record and does not work for all the other records but trigger works properly when records are inserted using cursor. Insert trigger updates few columns of destination table. To insert bulk data I am using following script INSERT INTO DestinationTable (Column1, Column2) SELECT * F...

query multiple databases for statistic purposes SQL

Hello all! I am trying to write a stored procedure that will allow me to write a single SELECT statement that runs on all databases on my SQL Server. (Microsoft SQL 2005) so far ive come up with the following procedure set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [sp_cross_db_query] @SQLQuery varchar(400) AS DECLARE...

SQL Server - Agent Proxy Error

Job History: Message Unable to start execution of step 1 (reason: Could not get proxy data for proxy_id = 4). The step failed. Agent Log: [442] CryptUnprotectData failed (1325). Server: Microsoft SQL Server 2005 - 9.00.3080.00 (X64) Sep 6 2009 09:15:46 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition (64-bit) on Wi...

SQL can I have a "conditionally unique" constraint on a table?

I've had this come up a couple times in my career, and none of my local peers seems to be able to answer it. Say I have a table that has a "Description" field which is a candidate key, except that sometimes a user will stop halfway through the process. So for maybe 25% of the records this value is null, but for all that are not NULL, it ...

Using SQL Server 2005 I'm trying to do a HAVING in a WHERE clause sound crazy?

Ok, I have over a million records and I need to select all information from the database where the count of a column is greater or equal to 10. I know that using having I must use group by and using where I cannot use aggregate functions with operators so what I want in pseudo code is Select column1,column2,column3 From MYdatabase Wher...

sql group by where statement

lets say i have this table user|group|acceptance 1 | a | -1 2 | a | 2 3 | b | 1 4 | b | 2 5 | b | 2 6 | c | -1 how do i get count how many users in each group have acceptance not -1 but still list the group having 0 count so result would be like group | count a | 1 b | 3 c | 0 thanks for the he...

SQL Server XML: massage xml format outside of SQL or within SQL stored proc?

Hi everyone, I have read through some excellent responses already dealing with SQL XML output posts, although what I need might not be a) best to do within a stored proc and b) not possible within a stored proc. My question is this: I have a simple table; col1, col2, col3, col4 .. for the purpose of an example, they are all just varch...

How can I clone records in a table and know the new and old ID?

Hi I want to copy N number of records within a table which is easy with a INSERT SELECT however after the insert I want a list showing oldId and newId. So lets say I have a SELECT statement which returns: ID | Name 3 | Test A 4 | Test B 5 | Test C If I do a SELECT INTO from this it inserts 3 new PKs. I want a list showing the new ...

SQL Server Reporting Service: can anyone explain this strange behaviour when counting rows with RowNumber?

While my initial problem counting the running number of rows in a table has already been solved, I would still like to know the origin of the following behaviour in SQL Server Reporting Service (I hope the example is clear enough): I created a report with the following dataset: select 1 AS Column1, 'First' AS Column2 union select 2 AS ...

[SQL Server] Reduce and Merge duplicate rows

Hi there, I have a table with the following sampled data: Name Color Alice Green Bob Black Chris Green Chris Black David Red Peter Blue Simon Blue Simon Red Simon Green Ultimately, I want to reduce the table by consolidating the Color column like: Name Color Alice Green Bob Black Chris Green,...

How to kill/resolve a reeeeally long-running update in SQL Server

A colleague of mine (I promise it was a colleague!) has left an update running on our main SQL Server since last Thursday (yes that's right folks, we're pushing 100 hours now!). The SQL in question (in one transaction, I might add) is: update daily_prices set min_date = (select min(a.date) from daily_prices a where a.key ...

Generate rows with index between two numbers

I have a single table varchar, int, int like this: OS MinSP MaxSP -- ----- ----- 2000 4 4 XP 2 3 Vista 0 2 7 0 1 What I want is a query which will generate a list of values like this: 2000 SP4 XP SP2 XP SP3 Vista Vista SP1 Vista SP2 7 7 S...

SQL server root Directory

Dear Friend, How can i Retrive Root Directory in SQL Server using SQL Query??? Thanks. ...

Concat Columns with NULL-values

I want to concat two Columns in the TableAdapter Wizard of the VS Dataset-Designer. The problem is that one column has NULL-Values and hence the concatination results in NULL regardless of the value of the other column. I've found out that i must SET CONCAT_NULL_YIELDS_NULL OFF, which is a Database option. How can i change this setting ...

SqlDependency throwing Invaild Operation exception

In our project we are invalidating the cache based on the change in the query output. This is implemented using change notifications. In the Global.asax file in the Application Start block we have also added SqlDependency.Start(ConnectionStr). But still its throwing the following invalid operation exception Message "When using SqlDepend...