Archived Months
January 2003
March 2003
April 2003
May 2003
June 2003
July 2003
August 2003
September 2003
October 2003
November 2003
December 2003
January 2004
February 2004
March 2004
April 2004
May 2004
June 2004
July 2004
August 2004
September 2004
October 2004
November 2004
December 2004
January 2005
February 2005
March 2005
April 2005
May 2005
June 2005
July 2005
August 2005
September 2005
October 2005
November 2005
December 2005
January 2006
February 2006
March 2006
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
October 2006
November 2006
December 2006
January 2007
February 2007
March 2007
April 2007
May 2007
June 2007
July 2007
August 2007
September 2007
October 2007
November 2007
April 2008


all groups > sql server programming > june 2006 > threads for wednesday june 14

Filter by Day: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

2 types of deadlock errors
Posted by Hassan at 6/14/2006 10:39:12 PM
1) Transaction (Process ID 110) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. 2) Transaction (Process ID 120) was deadlocked on lock | communication buffer resources with another process and has been chosen as the de...more >>

where can find the SQLDMO reference?
Posted by beelzebub918 NO[at]SPAM hotmail.com at 6/14/2006 10:10:17 PM
I don't konw how to use SQLDMO, I want to find the SQLDMO reference, Who = can tell me!Thanks!...more >>

Help with Stored Procedure
Posted by trevorjhughes NO[at]SPAM gmail.com at 6/14/2006 8:56:07 PM
Hello All I am trying to use a stored procedure to insert a record into an SQL Server 2000 database, however I have recieved the following error message: ODBC--call failed [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '20060615',(#170) I am using a pass-th...more >>

Help with SQL Query
Posted by Liddle Feesh at 6/14/2006 8:33:24 PM
Dear group, I need to create a stored procedure to return some data. The trick is the data needs to be AGGREGATED with a SUM of commissions against each line for each broker... I have a table (TRADE) with the following data: trade_id (PK), broker_id, tradeType_id, commission_amount, dat...more >>

Count how many times a character appeared in a string
Posted by AC at 6/14/2006 8:13:50 PM
Hi all, I'm having trouble googling this problem ... Would anyone know the easiest way to obtain the number of times a character appeared in a given string? Thanks AC ...more >>

Inserting Records, Skipping Duplicates
Posted by wrytat at 6/14/2006 7:30:02 PM
I'd like to ask if there's any statement to insert records into a table, such that if any record violates the primary key constraint, it will "neglect" the record and insert the next one. Thank you...more >>

Change Notifications
Posted by Renjith at 6/14/2006 7:25:08 PM
Hello I have a requirement to update the Exchange contacts folder according to a table in MSSQL 200. Also changes in the db has to be updated in the contacts. The solution that I have thought about is to write a trigger and contact a COM object that does the update. Is there a better way to d...more >>

Re sort
Posted by Taha at 6/14/2006 7:20:48 PM
Hi all I Have Table Num As Int , Name As NvarChar(20) I Need Trigger to Resort The Field Num When I Change The num Num Name 1 aaaaa 2 bbbbb 3 cccccc 4 ddddd I Want when I Change the Num...more >>



query to find sales person who did sale every quarter
Posted by VJ at 6/14/2006 6:41:38 PM
I have this query which gets only those sales people who made a sale each month from Feb 03 - May 03. I need to change it to get sales person who did sales for each quater. so instead of comparing for each month quaterly comparison would be done. Here the range of data is from Feb 03 - May 03 bu...more >>

How Persistent are Derived Tables
Posted by Mike Harbinger at 6/14/2006 5:35:20 PM
In SQL Server 2000: If I create a derived table as follows SELECT ..... FROM Cust INNER JOIN ( SELECT Orders.CustID, SUM (Invoice.Amount) FROM Orders INNER JOIN Invoice ON Orders.InvoiceID=Invoice.ID AND Orders.E...more >>

Stored Procedure and Trigger Programming books
Posted by Manuel Toranzo at 6/14/2006 5:30:48 PM
Are there any good books on Stored Procedure and Triggers? ...more >>

Deleting Duplicate Records
Posted by ngorbunov via SQLMonster.com at 6/14/2006 4:41:01 PM
I have a table tmPunchtimeSummary which contains a sum of employee's hours per day. The table contains some duplicates. [code] CREATE TABLE [tmPunchtimeSummary] ( [iTmPunchTimeSummaryId] [int] IDENTITY (1, 1) NOT NULL , [sCalldate] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL...more >>

identify what tables are used in trace
Posted by daveygf NO[at]SPAM gmail.com at 6/14/2006 4:26:28 PM
What is the best way to identify what tables are selected, updated, inserted, or updated in a sql profiler trace? ...more >>

Is this possible? SQL Server 2000 Write times
Posted by Shawn Ferguson at 6/14/2006 4:25:25 PM
I created an online application for one of our educational programs. The = data is inserted via website entry -> client side validation -> stored = procedure -> database. Given a table stucture as follows, if 100 or even = 1000 people applied at the exact same time using an online application, ...more >>

how i can make script Database with Data?
Posted by Tark Siala at 6/14/2006 3:57:40 PM
hi i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise + SP4. i have database contains Tables, and i want make script to build Tables on other Database, but i need this script include Data in Tables too, i can make that ? and how? thanks -- Tarek M. Siala ...more >>

Count rows to max value
Posted by Griff at 6/14/2006 3:57:24 PM
Hi I'm writing a web search application that utilises AJAX. The idea is that as someone types in their search term, the page constantly tells them how many items (rows) the current search term is likely to return. So...the SQL. The stored procedure could be something like: selec...more >>

Need a guru
Posted by Big Ern at 6/14/2006 3:36:01 PM
To all guru's: I have something that sounds simple in theroy, but I haven't quite figured out what I need to do to accomplish this. Simply put here is what I'd like to do. 1. User logs into database/application 2. Upon login, update a table that contains the users login name (not sysxlo...more >>

Advice Requested on Primary Key: Is char(20) better than binary(20)
Posted by Russell Mangel at 6/14/2006 3:32:04 PM
I am not posting the DDL because it is not relevant to my question. So far I have been unable to find a decent "natural key" for a table I am designing. The true "natural key" is varbinary(MAX), which is unusable, and so I have to consider a surrogate key, which is using SHA1 agorithm to ge...more >>

a count query
Posted by Carlos at 6/14/2006 2:55:00 PM
Hi all, I need to built an efficient query that would be able to tell me the amount of times that the field 'mark' has an 'x'. It should count only one time for a given id. In the following example for id 23 the count should be only 1 even though it occurs more than once. At the e...more >>

Totals and Average from multiple tables
Posted by Deki at 6/14/2006 2:43:02 PM
Hello, I'm trying to combine 4 statements below into one that will give me results that will be in this format: BPSName Total(X+Y+Z+W) ________________________ Mike 23 John 44 Gus 63 .... 4 statements: SELECT tb...more >>

SqlCacheDependency - Cache.Insert not working
Posted by Marc Castrechini at 6/14/2006 2:15:22 PM
Once again, just trying this out so please correct my obvious errors ... I can not seem to get Cache.Insert to work if I pass it a SqlCacheDependency. If I don't pass the dependency then it works fine. Here is some code from my DataAccess layer (thats why I am using HttpContext.Current). ...more >>

UNION ALL natural order
Posted by ionFreeman NO[at]SPAM gmail.com at 6/14/2006 2:14:36 PM
I have this belief that the first result set in a UNION ALL query will come first. So select * from authors where au_id = '427-17-2319' UNION ALL select * from authors in the pubs database will prepend Ann Dull's record to the results. However, this is not what Books Online says. Am I correc...more >>

Difference in these two queries
Posted by Jeremy Chapman at 6/14/2006 1:51:43 PM
I've included two queries below, which give me the same result and it seems the query plan ends up being the same. Is there any benefit of writing it one way over the other? SELECT o.[id], o.[lastname], o.[firstname], o.[startdate], a.[timestamp], o.[manager] FR...more >>

join vs where
Posted by nick at 6/14/2006 12:36:02 PM
1. select .... from T1 inner join T2 on T1.c=T2.c where T2.c1 = '...' 2. select .... from T1 inner join T2 on T1.c=T2.c and T2.c1 = '...' Any reason not use the approach 2? ...more >>

convert hexadecimal datetime to normal datetime
Posted by Chris at 6/14/2006 12:23:02 PM
Hi, I have a field of timestamp datatype. The data is hexadecimal. I would like to create a function or query the field so that I can see it as normal 00:00:00 format? It would also be nice to be able to query the field by entering a 00:00:00 value but it searches the field in the hexade...more >>

help with a query
Posted by VJ at 6/14/2006 11:12:41 AM
i have a table with sale_id , sale_object_id for each sale_id there can be multiple sale_object_id's but not 2 same sale_object_id in each sale sale_id sale_object_id 1 100 1 120 1 140 2 100 2 120 ...more >>

I've never seen this before
Posted by Christian Smith at 6/14/2006 10:34:42 AM
I saw something today that I had never noticed before. A collegue of mine and I were troubleshooting a query that was not performing as expected. The query consisted of a Select from a complex view with a where in subquery. In all, the query was taking about 30s. The subquery runs quickly w...more >>

Stored Procedure Causing Deadlock
Posted by LisaConsult at 6/14/2006 10:08:01 AM
I am not very familiar with handling deadlocks. I've identified the SP that is causing the deadlock, but I'm just not sure how to write it any differently. Basically we are conforming records from an old system to the new system. This happens on a hourly basis as old events are re-opened. ...more >>

View performance
Posted by gellis99 NO[at]SPAM aol.com at 6/14/2006 10:05:48 AM
We have created a web app that has it's own database. The web app has been designed to work with multiple third party loan origination systems. In order to reduce the work required to install the web app along side various other systems, we created views in the web app database that call views...more >>

Eliminate Rows with Redundant Columns
Posted by Mike Harbinger at 6/14/2006 9:47:32 AM
I would like my query to return the KeyID from row 4 but from only one of the first 3 rows where the address data is redundant. Since use of the key eliminates the DISTINCT operator, is there another method? DECLARE @tAddress TABLE (KeyID int, Address varchar(10), City varchar(10), ST varch...more >>

Memory Use
Posted by len at 6/14/2006 8:47:01 AM
Hi there. I have an application that connects to a SQL Server using ODBC (and CRecordSets) to peruse and retrieve data from a number of large database tables. As a result, SQL Server seems to be constantly using up a very large amount of memory - even when my application doesn't seem to be ...more >>

Problem mit Stored Procedure
Posted by david.ehrler NO[at]SPAM zone3000.ch at 6/14/2006 8:45:46 AM
Die folgende Stored Procedure (MS SQL Server 2005 Express) verursacht folgende Fehlermeldungen: "Meldung 4104, Ebene 16, Status 1, Prozedur GetNextSequence, Zeile 11 Der mehrteilige Bezeichner "dbo.Text.text_id" konnte nicht gebunden werden. Meldung 4104, Ebene 16, Status 1, Prozedur GetNextS...more >>

Select / Group By First Word in Column
Posted by Harry at 6/14/2006 8:30:10 AM
Hi, Could anyone tell me if this is possible: If i have a table like follows: Col1 John Smith John Jones Ann Smith Ann Thoms John Peters I want a query to group by the first name, so is there anyway to select the first word and then group by it. ie: My desired result is: First ...more >>

Extracting data types
Posted by Alur at 6/14/2006 8:16:02 AM
How is it possible to take out all data types ? Which procedure( function, view) should I use ? ...more >>

SQL mail login pwd
Posted by john d at 6/14/2006 8:15:02 AM
We have an alert system set up on SQL Server but the login and pwd is not documented. If we change both, what if any negative impact can we anticipate? To our knowledge there are no hard coded login/pwd calls....more >>

DENY SELECT on SCHEMA issue
Posted by christophe.leroquais NO[at]SPAM gmail.com at 6/14/2006 7:36:07 AM
Hi, I want to deny select on many views/table so that my excel users won't access them. 1. USING DENY SELECT ON VIEWS/TABLE deny select on sys.all_columns to loana deny select on sys.all_objects to loana ....etc... -> This works fine but takes ages for going throgh all the views/tab...more >>

Numeric or Int to store prices
Posted by frederic NO[at]SPAM naar.com at 6/14/2006 7:32:59 AM
Hi, I am upgrading tables on a legacy SQL Server 2000 database Some price data is stored in real datatypes, which is not correct. Prices are in Euros and I just need 2 decimals. I could convert them to numeric or use integer multiplying values per 100 then dividing on them on the presentation...more >>

Type determining
Posted by Alur at 6/14/2006 7:22:02 AM
How can I determine the type of some value ?...more >>

Select Count
Posted by Senna at 6/14/2006 6:20:02 AM
Hi Am looking around for interesting performance tips and one was to use 1. SELECT rows FROM sysindexes WHERE id = OBJECT_ID('Table1') AND indid < 2 instead of SELECT COUNT(*) FROM Table1 Is this a best practice to use? 2. Whats the benefits of using dbo.Table1 instead of just T...more >>

SP updates my fields to NULL
Posted by Mark at 6/14/2006 6:19:47 AM
Hi - my SP below, update two fields to Null, it should update them to the minimum value in @ci and the maximum value in @co - can anyone please advise what I'm doing wrong? Create Procedure updateStartEnd { @cust_ref bigint, @car_id bigint } AS declare @ci datetime declare @co datetime ...more >>

SqlServer 2005 OUTPUT Clause
Posted by S Chapman at 6/14/2006 6:09:09 AM
I was very happy to read about the OUTPUT clause in SqlServer but I don't know if I am missing something but I find it quite limiting. Here is how I am using the OUTPUT clause to return the new valuess: CREATE PROCEDURE [ExpData].[GSP_PortfolioGroup_Create] @PortfolioGroupNu...more >>

MSDTC Unavailable Windows 2003
Posted by Ronan at 6/14/2006 5:46:02 AM
Hi I have a VB6 windows app which calls a VB6 COM+ application (both running on machine CHOPGBCOM001) which in turn calls a stored procedure on a remote machine CANSUR001 but it keeps failing with error "MSDTC on server 'CANSUR001' is unavailable". The COM+ application is configured wit...more >>

SQLCMD / ISQL /OSQL - Rows affected message
Posted by JasonDWilson at 6/14/2006 5:45:02 AM
When running a command line query via SQLCMD, ISQL, OSQL, etc., is there away to turn off or not display the rows affected message so that it will not be displayed? I just want the results of my command line query nothing else. -- Jason...more >>

Derived Column in CREATE TABME
Posted by Kurlan at 6/14/2006 5:36:02 AM
Hi champs, I am kicking my self for the syntax for a derived column in a CREATE TABME -statement. I just wnat a extra colum that is the result of colum1+colum2 ... CREATE TABLE [dbo].[test]( [colum1] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [colum2] [nchar](10) COLLATE SQL_...more >>

alter table
Posted by Taha at 6/14/2006 5:15:45 AM
Hi All How can I Change The column Name in The table whit out drop it column_b ----- to -----column_c ALTER TABLE doc_exa (ADD) column_b VARCHAR(20) NULL ...more >>

The query engine on WHERE conditions
Posted by Senna at 6/14/2006 5:09:01 AM
Hi Wonder how the query engine works. Say I have a query like this. SELECT * FROM Product WHERE StoreId = @storeid AND Id = @productid AND IsActive = 1 Say that (StoreId = @storeid) returns true but (Id = @productid) returns false does it still go and check (IsActive = 1) or...more >>

Help with a query
Posted by Josema at 6/14/2006 4:53:01 AM
Hi to all, Im using a query like this: select A.AfectadoApellidos as Apellido, A.AfectadoName, A.AfectadoDNI,(Convert(varchar,TA.TipoAccionBreve)+Convert(varchar,Empresas.EmpresaBreve)+Convert(varchar,E.ExpedienteIncidenciaID)) as Codigos from Expedientes E inner join Afectados A on ...more >>

Retrieve Primary key coloumn by querying system table of Sql server 2000
Posted by shailbpl NO[at]SPAM gmail.com at 6/14/2006 3:07:32 AM
Hi, How can i retrieve primary key columns including foreign key ( part of primary key) by querying system tables of sql server 2000. I want to know that how many columns are primary key column in table. Pls help. Thanks in advance Shail ...more >>

Managed vs SQL Stored Procedure....
Posted by Hiten at 6/14/2006 2:13:22 AM
Hi Any one able to give comments on "Dose managed stored procedure hit the application performance compare to normal sql procedure?" Now take the example, There are 10,000 rows having 40 columns now spliting & inserting these records in 8 tables How much time and resources will be consu...more >>

Execute SQL dynamically
Posted by Ferreira at 6/14/2006 2:09:02 AM
Hi, I want to execute some SQL statement that has more than 4000 characters, is there any way to do it? I'm using the exec sp_executesql command as following: declare @SQLString nvarchar(4000) select @SQLString = 'SQL statement more than 4000 characters' exec sp_executesql @SQLString T...more >>

divide by zero error
Posted by Rajeev at 6/14/2006 1:09:42 AM
Hi, I have a query like this. don't look at from part i have a problem with the SET part. UPDATE DSREA Set HostAmt = ROUND(CONVERT(MONEY,(((CONVERT(FLOAT, DSREA.HostAmt)) / ISNULL(ER1.ExchangeRate,1)) * ISNULL(ER2.ExchangeRate,0))), 4) * CASE DSREA.DebitFlg WHEN 1 THEN 1 ELSE -1 END...more >>

Trigger, multiple tables and transactions best practices?
Posted by Mark S. at 6/14/2006 12:08:14 AM
-- which is best? -- trans per table CREATE TRIGGER trMyTrigger ON tbTable INSTEAD OF INSERT AS BEGIN -- PRODUCTS BEGIN TRANSACTION UPDATE tbProducts SET prodName = 'abc' INSERT tbProducts SELECT prodName FROM INSERTED COMMIT TRANSACTION -- EMPLOYEE BEGIN TRANSACTION UPD...more >>

How to Get Using Query
Posted by Prabhat at 6/14/2006 12:00:00 AM
Help need to get records from this "Trans" Table: TransID CustomerName LicenseNo ProductID Price DtOfSale 1 Prabhat 0123456781 10 125 2 Prabhat 0123456782 20 123 3 Prabhat 0123456783 30 ...more >>

selecting only the month/year part of a date value
Posted by Aussie Rules at 6/14/2006 12:00:00 AM
Hi, I am trying to group results based on the date of the transaction. The date field is a normal datetime field, so returns the full date time value. How do I just get the month and year bit, so i can select all transactions in say May-2006, and then i will be able to easily group on that...more >>

Problem in stored proc with a null value in dynamic SQL
Posted by Aussie Rules at 6/14/2006 12:00:00 AM
Hi, I have a stored proc which builds a string of dynamic sql. The problem is that i have some parameters i pass to the stored proc which is used to build the dynamic sql. If one of these values is null, then the dynamic sql i am building is set to null.. is sql = 'select col1, col2 f...more >>

comparing query results
Posted by Justin at 6/14/2006 12:00:00 AM
1. What is the best way to compare efficiency (performance) of two different queries that return the same result in general? 2. What if one contains user defined function one query and another without user defined function? The reason I am asking this is that the optimizer's cost model do ...more >>


DevelopmentNow Blog