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 > october 2004 > threads for tuesday october 5

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 31

percentages of top 10 tallies
Posted by a NO[at]SPAM b.com at 10/5/2004 11:07:24 PM
i have the following query: select top 10 bb.brand, count(bb.brand) as tally from participant p, beerbrands bb where p.favbeerid = bb.beerid group by bb.brand order by tally desc it will give me the top 10 brand, and count of that brand. Fine. But I need a 3rd column which is the percenta...more >>

AND Vs WHERE
Posted by Amit at 10/5/2004 10:25:10 PM
Hi Sql Gurus, Written below are two queries returning the same result set. SELECT A.Col1 FROM TableA AS A INNER JOIN TableB AS B ON (A.Col1 = B.Col1) AND (B.Col2 = 5) SELECT A.Col1 FROM TableA AS A INNER JOIN TableB AS B ON (A.Col1 = B.Col1) WHERE (B.Col2 = 5) Above two queries see...more >>

SQL to get relationships
Posted by Gridlock at 10/5/2004 9:41:04 PM
Anyone know what the SQL is for getting relationships for either the entire database or for a selected table? Any help will be greatly apreciated....more >>

strange behaviour
Posted by Abhishek Singhal at 10/5/2004 9:01:27 PM
Hi All I am facing a strange kind of behaviour in sql server. I am executing a query like the following: select id, sum(amount) from (select distinct id,amount,xx,yy from purlistitems() ) as t1 group by id this query is taking a very long time [in fact i get a timeout on client]. when i ...more >>

Design alternatives for row possibly larger than 8k
Posted by Elaine at 10/5/2004 6:33:47 PM
I have eight memo datatype columns in Access which currently hold a max of 4300 characters each (not all fields are always used but they possibly can be), so when I convert to SQL Server, I won't be able to use varchar for these fields since they would make the row size too large. It seems te...more >>

stored procedure
Posted by LouD at 10/5/2004 6:33:06 PM
Hello, I am trying to create a stored procedure that prompts the user and searches on any part of a field. I have tried using the Like criteria, but I can't get it to work correctly. Here is what I am using now: = @Enter_City Users have to type in the whole name of the city this way. ...more >>

Bit vs tinyint for new database accessed by C#
Posted by Vern at 10/5/2004 6:15:02 PM
I'm setting up a new database and am wondering if I should use bit or tinyint for a field that will indicate if a building has a basement. It would need to store 0,1,Null (Null if they are unsure if it has a basement). In C#, it would be nice to be able to have the IF statement look somethin...more >>

If Update fails, then Insert....
Posted by Ace at 10/5/2004 5:28:47 PM
Hello, I am trying to update a record. If this update fails because no such record exists, then I would like to insert this record into the table. Would this be possible? Thanx, SK ...more >>



Check duplicate/overlap record by time
Posted by K.K. at 10/5/2004 5:19:11 PM
Hi all, I have a vb6 app that allows supervisors to arrange shift for their people. On the vb form there are Date, Start time, End time field which will be validated before saved into DB. What I want to do is to check is there any Overlap shift for an agent in DB, so I can prompt an erro...more >>

I want to change the instance
Posted by Sridhar K at 10/5/2004 5:01:04 PM
Dear all, Since my SQL server instance is in the name of (local). i am not able to configure the replication on my sql server. How do i overcome this problem ? Yours Sridhar K ...more >>

"DataSet" input parametes to Stored Procedures
Posted by Patrick at 10/5/2004 4:57:47 PM
I need to pass in 2 lists/dataset to a stored procedure (from a .NET application). I don't think in TSQL, you can pass in a "DataSet" (like you could with Oracle), right? How could I get around this problem? I *can* pass in a comma seperated list of varchar, but there is a limit on the size ...more >>

text vs varchar
Posted by tshad at 10/5/2004 4:50:01 PM
What is the max length of text and varchar? I thought I saw varchar's max size as 8000 (not sure if right here). I want to store some long text that could be about 4000-5000 characters (including line feeds). I am curious as to which type would be the best to use and why (or maybe binary ...more >>

Re: error validating the formula for column
Posted by Ponnurangam at 10/5/2004 4:13:16 PM
Even [firstname] + [lastname] or firstname + '-' + surname does not work Hope someone helps me out Thanks Ponnurangam ...more >>

Re: error validating the formula for column
Posted by Ponnurangam at 10/5/2004 3:57:02 PM
I am trying this in sql server enterprise manager, does this has something do with the error Ponnurangam ...more >>

Re: error validating the formula for column
Posted by Ponnurangam at 10/5/2004 3:47:44 PM
Even APPLICANT_FIRST_NAME + APPLICANT_LAST_NAME does not work I am getting the same error Thanks Ponnurangam "Jacco Schalkwijk" <jacco.please.reply@to.newsgroups.mvps.org.invalid> wrote in message news:<u4vrIMsqEHA.1992@TK2MSFTNGP09.phx.gbl>... > Concatenating strings in Transact-SQL...more >>

error validating the formula for column
Posted by Ponnurangam at 10/5/2004 3:33:19 PM
Hi, I have three fields APPLICANT_FIRST_NAME, APPLICANT_LAST_NAME and APPLICANT_NAME While designing table in sql enterprise manager I am inserting "APPLICANT_FIRST_NAME & APPLICANT_LAST_NAME" for Formula Value of APPLICANT_NAME field But I am getting the following error "Error Valida...more >>

Duplicate data within a field
Posted by Terri at 10/5/2004 3:30:22 PM
Any help would be appreciated. I have a field that may contain the same data twice with no delimitation. How can I identify these records. If I do something like: SELECT left(address1,5)As left5 FROM SYSDBA.Address I can get the 5 characters on the left. How can I check the remainder of the ...more >>

SQL Question
Posted by Subhash Agarwal at 10/5/2004 3:05:54 PM
I will try and explain my problem with the following example: create table #tt (s1 int, st char(2)) insert #tt select 1, 'NE' insert #tt select 1, 'FL' insert #tt select 2, 'NE' insert #tt select 2, 'FL' insert #tt select 3, 'NE' insert #tt select 4, 'FL' insert #tt select 1, 'MN' ...more >>

Clarification on Substring
Posted by Mike Labosh at 10/5/2004 3:03:37 PM
From BOL Substring function topic: <snip> Note Because start and length specify the number of bytes when SUBSTRING is used on text data, DBCS data, such as Kanji, may result in split characters at the beginning or end of the result. This behavior is consistent with the way in which READTE...more >>

ASP.NET with SQL image type for up/down...
Posted by TJ at 10/5/2004 2:49:10 PM
Hi, I've written code web-based uploading and downloading. Here is some code for it. For saving file into MS-SQL database, SaveFileIntoDB(HttpPostedFile file) { int fileLength = file.ContentLength; byte[] fileContent = new byte[fileLength]; int lastPos ...more >>

Clustered vs Non clustered
Posted by Drew at 10/5/2004 2:46:04 PM
Can someone give me Examples where Non Clustered index is better than clustered Indexes Thanks ...more >>

Internal Query Processor Error
Posted by elstx at 10/5/2004 2:29:04 PM
While attempting to insert a large amount of data into a text field received the following error: Internal Query Processor Error: The query processor ran out of stack space during query optimization. The data being inserted contains several Char(10) values imbedded for formatting. If the C...more >>

Why doesn't this generate an Error Message?
Posted by David W Clary at 10/5/2004 2:03:03 PM
Look at the following line of code, for use with the NORTHWIND DB... select employeeID from employees where employeeid in (select employeeid from customers) Obviously, if you ran the subquery by itself -- select employeeid from customers -- you'd get an error message: Server: Msg 207...more >>

how to limit size of record returned
Posted by Paul at 10/5/2004 1:51:05 PM
Hi just wondering if there is a way to limit the size of a record returned from a stored procedure? The procedure has SELECT table.field1 FROM TABLE WHERE () field1 is a varchar 50 but I am sending the output to a dataset and then a crystal report and want to chop the characters at 2...more >>

A trigger that prevents a duplicate value based on a foreign key v
Posted by beacon-dartmouth at 10/5/2004 1:27:01 PM
I need to come up with a trigger that would prevent an insert if the value of the column "Logical_Name" is a duplicate of another with the same value in the "Table_ID" column. In other words, I have two tables (Table and Field) where there may be one or more instances of a field for one ta...more >>

How to pass column name to a stored proc as a parameter
Posted by vibs at 10/5/2004 11:43:09 AM
I have to pass column name dynamically to a stored proc as I will not know the column name to be queried on, how can I write this SQL Thanks!...more >>

Thank you for making SQL Server so good.
Posted by SQL Apprentice at 10/5/2004 11:41:49 AM
Thanks to everyone for all the great advices you have given me. This community makes SQL Server a much better environment than other RDBMS. ...more >>

Date Query Problem
Posted by JP SIngh at 10/5/2004 11:38:16 AM
Hi All I am not quite so good with SQL Server query so wondering if someone can help. I have a two tables one called empProfile which has fields UserId, FirstName, LastName and a table called holidayrequest which has fileds UserId, DateFrom, DateTo We store employee details in the...more >>

good book on SQL server introduction and programming
Posted by bill at 10/5/2004 11:31:51 AM
I would like to know more about SQL server programming. Could you recommend me a good book on that? I know basic stuff of database not SQL server specific. Thanks for your help. ...more >>

IDispatch error #7786
Posted by Norbert at 10/5/2004 11:07:41 AM
Hi all! One think with the MS SQL server that really gets on my nerves are the beautiful descriptions for dispatch errors. The other day, we got a IDispatch error #7786 (description: unknown error), and my boss insists that we find out why this happened. I looked around, and found nothing. ...more >>

split data
Posted by Jean at 10/5/2004 11:03:01 AM
Hi, I have two tables. One table (table 1) just has data for look up. ID Product_Name C01 product 1 C02 product 2 B01 product 3 ........................ The other table (table 2) has the data that need to get product name using the ID. However, the IDs in this ...more >>

Composite Key of Different Data Types
Posted by Elaine at 10/5/2004 11:02:49 AM
Old Access db table has a character PK - example would be "C150-04" or "S405-03". The "C" and "S" indicates the type of specimen, the "04" and "03" tell me the year the specimen was taken, and the "150" and "405" tell me the label number of the specimen. Label numbers are pregenerated in numer...more >>

Cascading delete confusion
Posted by drewdetwiler NO[at]SPAM gmail.com at 10/5/2004 10:51:57 AM
This is my first posting, and I'm not a SQLDBA, so take it easy on me. In an application I'm working on, we use stored procedures to permanently remove a record from the database. Our initial design had no cascading deletes turned on for a couple of reasons. 1. We were planning on only dea...more >>

Storing Fonts in SQL Server
Posted by Maddy at 10/5/2004 10:45:02 AM
I need to store several different fonts in a SQL Server 2000 db for a GUI (C#). What's the best way to store a Font (Family, Style, Size, Color) in a table column? Does it need to be a different column for each of these properties (string, string, int, int)? thanks -- Maddytk...more >>

How to remove Not in or <> from where clause of the SQL statement.
Posted by kjsgrp NO[at]SPAM gmail.com at 10/5/2004 10:39:06 AM
Hi Friends !! The following query has been given me the result expected but it is not picking up the cluster indexes due to <> (not equal to) operand in the where clause. SELECT SO.ORDERID, OS.[DESCRIPTION], CM.FIRSTNAME, CM.LASTNAME, CM.EMAIL, CM.CUSTOMERID FROM TBLMASTERORDERSTATUS OS I...more >>

Trigger Question
Posted by Amy at 10/5/2004 10:28:43 AM
I am trying to create my first trigger and I am not getting the results I would expect. Could someone take a look at my code below to help? When a record is added to the company table, I want to add the same id and company name to another table (queue table). The id is not an identity...more >>

Updating big table in a batch
Posted by Mark at 10/5/2004 10:17:50 AM
How would you update all rows in a big table in a batch. Create Table dbo.Test (col1 Int NOT NULL) DECLARE @i INT Select @i = 0 WHILE @i <= 1000000 BEGIN INSERT INTO Test VALUES (@i) Select @i = @i + 1 END NOW I wanna update all 1 M rows using update stmt UPDATE Test SET c...more >>

Stored Procedure syntax problem
Posted by Ken Briscoe at 10/5/2004 10:17:27 AM
Here's the deal...I'm trying to rewrite a Crystal Report that made use of 11 subreports as a Stored Procedure. The user selects an Item Class, and the report spits out total quantity sold and avg price for each of the 11 customers on the report, for either the top 65 or top 125 most stocked items...more >>

EBCDIC in SQL
Posted by Serena at 10/5/2004 10:09:05 AM
How do I convert the results of a sql query to EBCDIC and export it? Thanks, ...more >>

String or binary data would be truncated.
Posted by Robert Taylor at 10/5/2004 10:02:35 AM
I am importing data from a temp table into a production table and I receive the message that the import was stopped because data would be truncated. Normally, just a nuisance to find the offending data. But here is the rest of details: The field I'm importing *into* to has a datatype of nvar...more >>

Obtaining Current Execution Status in T-SQL
Posted by steve at 10/5/2004 9:58:33 AM
I start a job using sp_start_job. I do not want to proceed without that job ending. How can I get the current execution status? I have tried to use sp_help_job and in job aspect "job" there is a column called current_execution_status. I want to wait until that execution status states th...more >>

Need to find TOP 5 within grouped results
Posted by Deborah Bohannon at 10/5/2004 9:48:43 AM
I am trying to find the TOP 5 TIN by State. I have tried to figure out how to do this, but I'm evidently approaching it wrong. Can someone please help? I have a query like this: select state, TIN, sum(totalcnt) totalcnt, sum(totalcharge) totalcharge, case sum(totalcnt) when 0 then 0...more >>

can my script create the dtproperties table?
Posted by Uri Dor at 10/5/2004 9:46:07 AM
Hello, everyone, I'm producing SQL scripts to recreate my database and storing them on my version control system. The scripts include INSERTS to the dtproperties table so my diagrams are recreated. The thing is that when I create a new database the dtproperties table doesn't exist. Can I cr...more >>

Searching Data from a WebSite
Posted by Mueller at 10/5/2004 9:38:25 AM
Can someone please point me to the information on how to write a search box into a page that will query a Catalog?...more >>

Command Timeouts
Posted by Charles Dana at 10/5/2004 9:32:31 AM
I have a program calling a procedure using the command logic that times out after 30 seconds. I have set the command timeout to 100 seconds and if I display the command timeout when the program fails after 30 seconds, the display shows that the command timeout is 100 seconds. Program vb ...more >>

Parameters between nested storedprocedures
Posted by CHD at 10/5/2004 9:31:02 AM
I have a vb application which calls stored procedure sp1. sp1 inturn calls sp2. I have a situation where I want sp2 to return a recordset (set of rows) to sp1 and then sp1 will perform some action/filtration and return remaining rows to the vb application. ...more >>

daily task, comparing data - how to go about it
Posted by mgm at 10/5/2004 9:29:05 AM
I've been asked to query a database and compile a list of certain orgs. then every day thereafter, if there is a new org, have an automated email sent out to the new org. I was thinking of possibly writing a script that queries the database and stores the resulting orgs into a table in my...more >>

Trying to optimize a query with a bunch of INNER JOINs
Posted by Scott Lyon at 10/5/2004 9:17:27 AM
I've got a table of data that also contains an ID column for a bunch of look-up tables. For example, let's assume I've got 3 look-up tables (each of which will have from 2 to 20 possible values): Code1: Code1_ID int (PK) Code1_value char(1) Code2: Code2_ID int (PK) Code2_value char(1)...more >>

Want to Order By a field not group by
Posted by M K at 10/5/2004 9:17:06 AM
Okay, simple example of my issue. I have a table like this: IdentField Field1 Field2 Field3 1 Yada Other B 2 Yada Other C 3 Anothe Other B 4 Anothe Other C I want to do a SELECT query that gives ...more >>

Consolidate Rows on Select
Posted by Dan at 10/5/2004 9:04:38 AM
I want to condense several rows of a table using a select statement, function, or stored procedure For Example mytable : 1 a 2 b 2 c 2 d 3 a so that my select should result in 1 a 2 b,c,d 3 a Any ideas or suggestions? ...more >>

retrieve date
Posted by CGW at 10/5/2004 8:51:03 AM
In a scheduled stored procedure, before I do a bulk insert, I want to make sure the downloaded file has today's date. What is the best way to retrieve the date on a file? -- Thanks, CGW...more >>

Why would I be getting this, it doesn't seem to relate or does it
Posted by Mueller at 10/5/2004 8:46:18 AM
Here is my code (Thanks to Mike): INSERT INTO dbo.SearchContent (SearchContent) SELECT RIGHT(CONVERT(varbinary(8000), dbo.WebParts.tp_AllUsersProperties),20) AS Data FROM WebParts Error: Cannot insert the value NULL into column 'Search_ID', table 'WSS_ContentDev.dbo.SearchContent'; co...more >>

Stored Procedure to filter or not to filter
Posted by Drew at 10/5/2004 8:37:28 AM
I need to be able to make my stored procedure, so that if the user enters NULL as the @EmpSSNEntry, then it doesn't filter by the SSN. But if the user enters a SSN, it does filter by that entry. So if the user wants a complete list of employees, they just have to enter NULL, but if they want...more >>

Updating multiple tables with one statment
Posted by theresasto NO[at]SPAM yahoo.com at 10/5/2004 8:19:45 AM
Need some help! I have a stored procedure to update multiple tables. The table name increments by year (tablename2000, tablename2001...). I would like to use just one statement that will update each table until the most current table (by year) has been completed. This way I won't have to m...more >>

Timeout with full text index
Posted by ENIZIN at 10/5/2004 8:11:04 AM
I am new to FTIs and I'm having a problem searching a text field in my database. I have a table that contains gene sequences that can be extremely lengthy (30K chars) so that is why I am using a text field. With that being said, I need to search this table using a portion of a full sequence wh...more >>

SQL Sum Question
Posted by J W at 10/5/2004 7:13:04 AM
Hi, I am wanting to Sum a column but i don't want the rows that have a BalanceAmt = 0 to be included in the total sum. Goes something like this... Sum(Note)FaAm, Sum(RefAmt)Ref, Case When Balanceamt > 0 Then Sum(TopofNote - AH - Taxes - Insur) Else 0 End LoanProce, ...I ...more >>

Locking... best options?
Posted by Anubis at 10/5/2004 6:37:11 AM
Hello All, I have a database which is very highly used. I am currently experiencing a very high level of transaction deadlocks and this is becoming a problem. I have read a little about locking in BOL however as I'm sure you all know it's not all straight forward. Currently I'm looking a...more >>

Date status question
Posted by Edoluveit at 10/5/2004 6:37:04 AM
I have a problem. I have a fairly big table of traffic records. This table store the record of all cars entering the premises. The table looks like the following: Ticket# Lic# dateentered Total_time 0011 aaa11 03/04/04 30 0012 aa...more >>

Distributed Transaction
Posted by kaumil at 10/5/2004 6:19:05 AM
i am having the problem where the query analyzer simply hangs when i execute the following: begin distributed tran select * from [Linked Server].dbname.dbo.test1 commit tran If i execute the select statement independent without the transaction statements, it runs fine. Please provide so...more >>

Restore transaction log at a specific time
Posted by hilaire.verschuere NO[at]SPAM netcourrier.com at 10/5/2004 5:44:03 AM
Hi, I would like to perform the restoration of a database at a specific time. My backup procedure was : at time T1: BACKUP DATABASE MyBase TO MyTape at time T2: BACKUP LOG MyBase TO MyTape at time T3: BACKUP DATABASE MyBase TO MyTape If I want to restore MyDatabe à time T1_2, bet...more >>

Working xp_sendmail still rolls back transaction
Posted by jonas.berling NO[at]SPAM knowit.se at 10/5/2004 4:48:20 AM
Hi! I have a VB app calling a set of stored procedures under a transaction on SQL Server 2000. A trigger being fired by one of the SP's calls xp_sendmail and a simple info mail is successfully being sent (i.e. it arrives to the recipient). The strange thing is that the transaction I created f...more >>

Flatten data
Posted by Mal at 10/5/2004 4:27:02 AM
I have data in this format ID ; Request ============= 1,A 1,B 1,C 2,A 2,B 3,A I want to change it to id reuqestA ; requestB ; requestC; ==================== 1 1 1 1 2 1 1 0 3 1 0 0 (the 1 and 0 re...more >>

Using User-Defined Functions within Queries...
Posted by Ali at 10/5/2004 4:25:03 AM
I am new to SQL Server, and am trying to implement something that's fairly common and well done in Oracle that seems to be wreaking havoc in SQL Server... I have several queries that use the same calculation. This being the case I created a user-defined function to be called by the queries, ...more >>

Real Dumb Question
Posted by Marek at 10/5/2004 3:38:26 AM
But I am going to ask anyway cos it's driving me nuts!! How do I hide system objects?? I just can't seem to find the option anywhere!! Regards Marek...more >>

râ„¢_2000_Analysis_Services_SP3
Posted by Ragugct at 10/5/2004 2:23:02 AM
Hi, Can any one of you give the path to download the "Microsoft SQL Serverâ„¢ 2000 Analysis Services SP3". Thanks in advance Ragugct...more >>

@@dbname??
Posted by Bonj at 10/5/2004 2:03:02 AM
You'd think there would be this, but it seems it doesn't exist? Is there any equivalent?...more >>

How many sunday are between date1 and date 2
Posted by Jesus Cardenas at 10/5/2004 1:36:31 AM
Hi to all gruop! How shuld be the select statment for this: I need to know how many sundays are between date1 and date2? Can any body help me? Thanks! ...more >>

Copy records
Posted by jamie at 10/5/2004 1:19:20 AM
I have table tmyTable like this. CREATE TABLE [dbo].[tMyTable] ( [IDTable] [int] NOT NULL , [IDxx] [int], [name] [varchar] (50) COLLATE Slovenian_CI_AS NULL ) ON [PRIMARY] GO ALTER TABLE [dbo].[tMyTable] WITH NOCHECK ADD CONSTRAINT [PK_tMyTable] PRIMARY KEY CLUSTERED ( [IDTab...more >>

Help - Query Problem - To Use Cursors or Not
Posted by Irishmaninusa at 10/5/2004 12:50:07 AM
Hello Everyone, I am trying to write a query that will pass in a value and pull back the JCode and the Qty used. So I have four JCodes Drug_Bill J1 - 50 J2 - 100 J3 - 500 J4 - 1000 Drug Id = 1001 I have done up my query and it gives me back the four records from the drug_...more >>

scripting data for a sql server user table.
Posted by checcouno at 10/5/2004 12:35:07 AM
is it possible to script data for a sql server user table? I'd like to script all my table, including data like for example INSERT INTO MYTABLE (myfield1, myfield2) values ('myvalue1', myvalue2) INSERT INTO MYTABLE (myfield1, myfield2) values ('myvalue3', myvalue4) INSERT INTO MYTABLE (myfield...more >>

order of columns
Posted by Bonj at 10/5/2004 12:35:02 AM
does anyone know, is it possible in T_SQL to do "alter table add [newcolumn]" but specify what order the column goes in, i.e. tell SQL server what column I want it to go before? You can do it with enterprise manager so there must be a way of doing it via SQL. ...more >>


DevelopmentNow Blog