sql-server-2005

using AVG aggregate function in sql server 2005

Hi I have one "orders" table: ID CustomerID Freight 1 VINET 32.38 2 TOMPS 11.61 . . . . . . . . . I want to select just those customerID s that have freight more than average!! SELECT CustomerID FROM Orders WHERE CustomerID IN(SELECT CustomerID,AVG(Freight) AVGFre...

Using MAX aggregate in SQL server 2005

Hi I have these two tables "Orders" and "Employees" Orders Table OrderID EmployeeID 1 1 2 1 3 2 4 7 5 2 . . . . . . Employee Table EmployeeID Firstname 1 Matin 2 Sina 3 Nima . . ...

Change path for default SQL Server trace

How do I change the path for the default trace in SQL Server? Can this be done with SQL Management Studio or do I have to use sp_configure Thanks ...

Update query on millions of rows fills the transaction log.

Hi, I need to update millions of rows as part of my next release, but doing so fills the transaction log and fails. I have a few ideas but I'm not a SQL expert so I'm sure there will be gotchas that I'm not aware of. Pertinent points: I need to hand a script over to the operations team so need a T-SQL method with no manual interventi...

Selecting a group of names

I am struggling with a query in SQL Server 2005-2008 There are 15 participants in a tournament. Every day, 7 random participants are chosen. Out of the 7, one is the teamleader. The condition is that if a person has become a teamleader once, he cannot become again till all the others (rest 14) have got their chances. How can i write ...

SQL, How to change column in SQL table without breaking other dependencies?

I'm sure this might be quite common query but couldn't find good answer as for now. Here is my question: I've got a table named Contacts with varchar column Title. Now in the middle of development I want to replace field Title with TitleID which is foreign key to ContactTitles table. At the moment table Contacts has over 60 dependencie...

can transaction be rolled back after its commited and connection is closed

finally { // Commit the transaction. sqlTran.Commit(); reader.Close(); reader.Dispose(); conn.Close(); conn.Dispose(); } i would like to give the user an option of opps! roll it back so its commited can it be rolled back? ...

is there any difference between these two questions that are related to queries?

Hi My friend ask me these two questions and make my mind busy would you please help me that is there any different between these two questions or they are the same as each other? thanks Consider that we have one table "Orders" Orders table OrderID CustomerID EmployeeID Freight 1 VINET 5 32.31 2 Nima...

prevent Empty Alert in reporting services

I am using report services to send an alert to users daily; my data source is an oracle DB. I want to send the alert, when my SELECT returns some records and don't want to send empty table to my users; if you want more info, just let me know thank you ...

Title: UPDATE is not allowed because the statement updates view "table_name" which participates in a join and has an INSTEAD OF UPDATE trigger.:

i am getting the following error while executing the following query in an Stored Procedure..Could anyone help in finding the fault? UPDATE is not allowed because the statement updates view "sup_item" which participates in a join and has an INSTEAD OF UPDATE trigger. UPDATE si SET name = mc.name, sup_item_cat_id = mc.res_sup_i...

Should I be using SQL transactions, while reading records?

SQL transactions is used for insert, update, but should it be used for reading records? ...

what is meant by distributed environment related to DBMS?

i know the general and the dictionary meaning of it, what does it mean when it said with respect to website and database designing? like let say make this and that for distributed environment, what events, what criteria should be used, coding method guidelines please thank you if this question is not in accordance to the rules ...

Replace CR with CRLF in a Textfield

Hello, i got some problem with replacing a CarriageReturn (CR) to a CarriageReturn LineFeed (CRLF) entry´s in a textfield on MS SQL 2005 System. There´s a table "notice" where a textfield "desc" is filled with some content which contains some CR. So some example is: Mister Smith "CR" Road 123 "CR" Germany I try to replace the CR with...

How to transfer SQL Server DB structure to another server

Tell me please what's the best way to copy db structure to another server? I'm trying to generate a script in Management Studio and then run that script on the remote machine. And I hate that thing. It works unpredictable, you have to fix manually a lot of crap in the generated script. I guess that isn't the best solution. Then I tried...

SQL Server - How to Grant Read Access to ALL databases to a Login?

I need to give a new login read access to all 300 databases on a server. How can I accomplish this without checking 300 checkboxes in the user mapping area? ...

how to find a sql field name that has a record like '%text%'

i want to search all teh fields in my DB to find the field names that have in them a string that contains some text. im trying to find a table and field responsible for some 3rd party software actions that i am aonly able to see the values for. i want to use these values to find the table and field they are stored in. ...

SQL Server query to create database is giving me an error when I include numeric characters in the database name

I am having trouble running a simple sql query in Microsoft SQL Server 2005 to create a database and im not sure why. When I run this query CREATE DATABASE 4444-virtual2 I receive this error Incorrect syntax near '4444'. Is there anything in particular that I must specify if I am creating a database table with numeric values in...

Error Object refrence not set to an instance if page is open for more than minutes

Hi, I had a problem with my internet explorer where when i refresh page the submit button the a page would also execute which was leading to double entry of data . for that i had to right the code for the refresh page where it wud clear the cache and session or it wud not enter last session values . from the time i implemented this co...

How to get the constraints on a table

By constraints I mean checks, not nulls, primary key constraint, foreign key constraint What sql querry to use Visual Studio 2008 / SQL Server 2005 Express Like for example to get table names commandString = "SELECT * FROM INFORMATION_SCHEMA.TABLES"; So what to get constraints. ...

ssis - flat file source - The process cannot access the file because it is being used by another process.

Am attempting to use SSIS flat file source to read a log file being actively written to. Looping and waiting for the file to be released is not practical as this is an active log file held by a service. Ideally, I'm looking for a setting upon the flat file source, similar to the C# code below. If not that, what route can I take to rea...