sql-server-2005

Problem updating table using IN clause with huge list of ids

Hi I am having a problem when trying to update a table using an IN clause, I have a big list of clients that should be updated 4500+. Update table set columnA = 'value' where ID in ( biglistofids ) //biglistofids > 4500 ids I am getting this error "String or binary data would be truncated." I tried the same script with fewer ids le...

Delete trigger is not working when fire from c# but working in sql server

i made a after delete trigger on a table1 and in this trigger i insert the deleted data in another table name tab2. when i execute the delete stored procedure of table1 from sql server 2005 then trigger working fine but when i execute delete stored procedure of table1 from c# then it is not working properly. Help me ...

Service Broker Design

Hi I’m looking to introduce SS Service Broker, I have a remote orders database and a local processing database, all activity on the processing database has to happen in sequence, this seems a perfect job for Service Broker! I’ve set up the infrastructure, I can send and receive messages and now I’m looking at the design of the processi...

Use stored procedure output parameter

ALTER PROCEDURE dbo.StoredProcedure8 @emp_code bigint, @co_id bigint, @p decimal(8,2) output AS SELECT @p = (select sum(tran_value) from emp_ded_ben_trans where emp_code=@emp_code and co_id=@co_id and period_flg=2 and tax_flg=0) RETURN ...

How to pass unknown number of parameters to sql query from C#?

I have a simple query where in FROM I've got something like: WHERE ([Comment] LIKE '%something%' OR [Comment] LIKE '%aaaa%' OR [Commnet] LIKE '%ccc') AND Replace([Number], ' ', '') = @number Unfortunetly this is now hardcoded in code so if anything changes (more OR's on the [Comment] field I have to go and change it in t...

Insert XML data into SQL Server table

My data looks like below: <products> <product ProductID="1" Price="79.99" Weight="30.00" Quantity="1"> <addon ProductAddonID="0" ControlTypeID="9" Price="25.00" Weight="0.00" Quantity="1" Name="yyy" Data="ASD" /> <addon ProductAddonID="89" ControlTypeID="0" Price="15.00" Weight="4.00" Quantity="1" Name="xxx" Data...

SQL Server - trying to convert column to XML fails....

I'm in the process of importing data from a legacy MySQL database into SQL Server 2005. I have one table in particular that's causing me grief. I've imported it from MySQL using a linked server and the MySQL ODBC driver, and I end up with this: Col Name Datatype MaxLen OrderItem_ID bigint 8 PDM_Structure_ID int ...

How can I make multiple records to be printed as a single row

This three columns are taken from 3 tables. In other words, these records are retrieved by joining 3 tables. It is basically a very simple time sheet that keeps track of shift starts time, lunch time and so on. I want these four records to show in one row, for example: setDate --- ShiftStarted --- LunchStarted --- LunchEnded ---- ...

The mdf data file wont shrink even if there is free space available

One of my databases had 450 GB of size for the data mdf file. I Dropped the unecassary tables to reclaim some space in the database and to my surprise even if there was around 150 GB of freespace, the data file won't shrink below the Files initial size which has grown to 450 GB. What could be the simplest solution/ workaround for this ? ...

Storing regional (slovenian) characters in the database

Hello This might be painfully obvious to some (most?) of you, however it has been bugging me for a while now. I have two databases running on the same SQL server (2005). As far as I can see they both have the same language/regional properties. Both have collation set to "Sloveninan_CL_AS" and yet one stores all Slovenian special charac...

Get values from all sub-divided child tables.

Hi All, I have three tables as below. TransactionTable ---------------- TransactionID Status Value FileNo (int) FileType - 'E' indicates Email, 'D' Indicates Document EmailTable ---------- EmailFileNo (Identity) ReceivedDate .... .... .... DocumentsTable --------------- DocFileNo (Identity) ReceivedDate ..... ..... ...

How Can I Customize Date Format

One of my table column's named "SetDate" of type DateTime looks as: 2010-08-02 02:55:58.420 The DateTime format from the application looks as: 2/11/2010 The problem is: I'm passing an SQL query to the DB via application. The query has WHERE clause which compares SetDate to the date coming from application. SetDate column carries ...

Incorrect syntax near 'ERROR_MESSAGE'

BEGIN TRY BEGIN TRANSACTION -- DO SOMETHIING COMMIT TRAN END TRY BEGIN CATCH IF(@@TRANCOUNT > 0) ROLLBACK TRANSACTION RAISERROR(ERROR_MESSAGE(), ERROR_SEVERITY(), ERROR_STATE()) --ERROR: Incorrect syntax near 'ERROR_MESSAGE'. END CATCH What wrong in the raise error statement? ...

connection string

Hi, I have created a simple members database in ASP.NET with login and create account features. Can anyone give an example of the correct connection string that I would need to use to connect to this database remotely. Any answers would be greatly appreciated. ...

SQL between dates but cut off at certain time and continue and certain time.

I have an MSSQL query that runs order productivity for a time period. Basically it calculates how long an order takes from start date to completion date in minutes. What I am doing is getting the date and timestamp where the order is created(a) and getting the date and time stamp where the order is completed(b) and subtracting them the...

How to escape parenthesis in SQL query?

Hello, Using Microsoft SQL Server 2005 - wondering how can I escape parenthesis in my query? I'm trying to find the string position of "(" in one of my columns returned, but Management Studio keeps thinking I'm opening another command when I use that. I've tried \ but that isn't escaping it. Thank you! ...

Connecting to a File share with a flat file source in SSIS2005

I have created a SSIS package in BIDS005 that uses a flat file source as the input. The file I am wanting to use doesnt exist on my local machine, or on the server where the package will be executed. The file exists on a file share on another server, however when I try to use the server path for example: \\servername\fileshare$\filename...

SQL Server error in '/' Application.

Hi, I have set up a small SQL Server database for users to login and also create accounts. I have uploaded the .sql file to the server and had it successfully imported. However when I test the pages online I am getting a Server Error in '/' Application (see code below). I was sure that I had done everything right but obviously not. Any a...

SQL dates to time to minutes minus work days.....confused

The following code has been created from a different post, but I now have a separate issue. What this code does is basically takes the 2 dates and subtracts weekends from it to get the overall time elapsed in minutes from start to end time excluding weekends. I am now trying to say since there is 11 hours in a work day for me I want to o...

SQL need to subtract certain time from date paramter passed into query

I have a date parameter so the date and time can always change. For this example the datetime is '2010-07-06 14:46:37.577' I need to see how much time is between this date paramter and the time of '17:00:00.000' The time of 5PM will never change but as I said the date paramter can change. ...