Groups | Blog | Home


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
August 2008
all groups > sql server programming > february 2004 > threads for tuesday february 24

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

@@ROWCOUNT
Posted by Andy Nava at 2/24/2004 11:44:28 PM
Hello, I have a sproc which I use to search through my member table in which visitors can page through the results. My sproc returns only the members I need for the current page, along with the total number of members that match the query using @@ROWCOUNT. In my sproc I use a temp table to...more >>


aba_lockinfo - new version available
Posted by Erland Sommarskog at 2/24/2004 11:12:16 PM
If you are using my lock-monitoring procedure aba_lockinfo, there is now a new version available at http://www.sommarskog.se/sqlutil/aba_lockinfo.html. I recommend that you replace your existing version with this one. Functionally, there are only minor difference, but the older version did no...more >>

Splitting a large query up into slices, and handing them off one by one
Posted by James Cooke at 2/24/2004 10:19:42 PM
Hi all, I am trying to retrieve rows from a table containing 500,000 rows. Using pure SQL, or a stored procedure, how can I "page load" this data, to retrieve+-30 rows or so at a time, and on demand of a button click. Using ADO.net. In other words, what is the method I would use to send the foll...more >>

SQL Query Needed
Posted by SP at 2/24/2004 8:27:25 PM
Hi all I need an efficient SQL Query I have 3 tables. 1. Students StudentID StudentName 2. Course CourseID CourseName 3. StudetMArks StudentID CourseName Marks Stuent and courses are many to many. I need to find out the studentnames who got the highest marks in...more >>

sub-query vs dynamic sql, error
Posted by Paul at 2/24/2004 8:21:05 PM
Any ideas on a better way to write this so that i don't get the following error: Exception Details: System.Data.SqlClient.SqlException: Syntax error converting the varchar value 'SELECT a_Users_Portfolios_Symbol.Portfolio_Symbol FROM a_Users_Portfolios INNER JOIN a_Users_Portfolios_Symbol ON a_Us...more >>

SQL query web site!
Posted by GS at 2/24/2004 8:20:52 PM
Hi all Is there any web site having some SQL Query problems and answers, so that I want to learn how to write the SQL statement efficiently. Thanks in advance GS. ...more >>

pre--importing
Posted by Geno at 2/24/2004 7:32:17 PM
Is it possible to have a script to parse or strip out elements in a text file before using the import function in sql all in one tasking? Thanks, Geno ...more >>

xp_cmdshell and vb programs and SQL Server 2000
Posted by Alex at 2/24/2004 6:56:49 PM
Does anyone have any issues with xp_cmdshell with SQL Server 2000 on Windows 2000 Server? The vb program runs but does not end properly. In other words, the task manager shows the vb program hanging there. The same program that shells out of SQL Server 7 on Windows NT has no problem. It'...more >>



Date comparison
Posted by Culam at 2/24/2004 6:55:40 PM
Hi, How do I compare two dates without matching the time. Example: Mydate TableDate in table (DateTime) 2/24/2004 2004-02-18 18:32:41.877 My below where statement does not work Where MyDate = TableDate Thanks in Advance, Culam...more >>

Stored Procedure vs C++ component
Posted by Marco Bolanos at 2/24/2004 6:07:12 PM
What would be more efficient, implementing complex code to manipulate data on a stored procedure or let a COM server do the manipulation and calculations through C++ code. We have an application that do all processing of data on SP and then give results back to a COM server. My concern is: is t...more >>

Datetime Semantics
Posted by Brad Leach at 2/24/2004 4:53:33 PM
Greetings, I have a situation where I have two tables that both have triggers to update an additional two history tables. For example, TableA TableA_History (TableA has a trigger which modifies TableA_History) TableB TableB_History (TableB has a trigger which modifies TableB_History)...more >>

Getting Max for time plus other fields
Posted by Catherine Lynn Wood at 2/24/2004 4:38:00 PM
I have a table that includes a primary key, a timestamp, a username, and an IP address. I use it to log access to a user area of a website, adding a new entry every time someone logs in. This is not a problem. Now I want to be able to tell people who are returning after logging in before whe...more >>

mark development DB
Posted by smk2 at 2/24/2004 4:26:26 PM
Is there a simple way to visually identify when the frontend app is linked to the development DB as opposed to the production DB? I have MS Access as the FE and would like some kind of visual clue as a reminder of which DB I'm linked to. Pretty newbie question, I know Thanks so much! SMK...more >>

BCP question
Posted by joe at 2/24/2004 4:13:01 PM
I have a huge table in a server, I want to bcp all the data to a DAT file (only data), then zip it up and move to other sql server. but I don't know how to do bcp. also, how do i do bcp out data from a DAT file to Table? ...more >>

Double-quoted unicode strings
Posted by Andry at 2/24/2004 4:06:16 PM
Hi How do I represent unicode string literals when SET QUOTED_IDENTIFIER is OFF, and I am using double quotes to represent string literals I tried N"somerandomstring" but it doesn't work. Seems that the 'N' prefix only works on single-quoted string literals Any ideas Andry...more >>

Personal SQL Server 2000
Posted by James Lattanzio at 2/24/2004 3:47:44 PM
Dear Anyone, I am a member of Microsoft's ISV program. I have a server running Server 2000 and a laptop as my workstation. The server is running SQL Server 2000. I want to install a desktop version of SQL Server on my laptop to do demos of my projects. Do I install from SQL Server D...more >>

How to compare prev with current rows in the table for each ID?
Posted by Kelly C. at 2/24/2004 3:46:24 PM
Hi Here is the problem. I need to go down each row of Table1 and compare the prev row's data with current row's data for each SUB, if the current row's data is different than the previous row's data for this SUB, then store this SUB current row's data in the new table, called NewTable. For Examp...more >>

How to make a 'periodic' website counter?
Posted by Welman Jordan at 2/24/2004 3:45:13 PM
Hello all, I saw some sites have periodic counters for each articles. For example, "this article has been read 134 times in the recent 7 days, 1049 times this month." I just wonder how this is implemented in SQL Server? Any ideas? ...more >>

Time interval
Posted by saso at 2/24/2004 3:44:36 PM
Hi! I want to select all records with a time between 16 and 20 every day during January. Like this: select * from report r where r.acc_date >= '2004-01-01' and r.acc_date < '2004-02-01' and DATEPART(hh,r.acc_date) >= 16 and DATEPART(hh,r.acc_date) < 20 Suppose I want to select all reco...more >>

Left outer join fails
Posted by Bjarne Anker at 2/24/2004 3:39:26 PM
I've got an Win2K Server running SQL Server 2000, and an Win2K3 Server running SQL Server 2000 SP3 (have to install SP3 on Win2K3 as far as i know). Anyway, my application select some data from a table using LEFT OUTER JOIN to another table. Something like this: Select a.1, a.2, b.1, b.2 from...more >>

Dynamic Search Conditions
Posted by Khurram Chaudhary at 2/24/2004 3:38:57 PM
Hi, I'm trying to write an SP to perform a dynamic search but am having a bit of trouble. In our app, you are able to select multiple selections from a list box such as City. I was thinking of using a WHILE loop to keeping adding on to the WHERE clause but that doesn't seem to work. Here's my ...more >>

Restrict number of connections to a databse.
Posted by Abraham at 2/24/2004 3:38:32 PM
Hi Is there anyway I can restrict the number of connections to a SQL Server database ? How can we do that.? Also what is the best way to find out number of current connections to the database using a query ? Thanks ...more >>

How should I store city, state values for addresses, please help.
Posted by JBLi at 2/24/2004 2:56:02 PM
Hi All, I am writting an real estate website for a company. I need some advices on how should I store fields like city, and state for addresses. Originally, I was thinking to store the city and state as numeric fields (in the main Houses table) and having extra one table for citie...more >>

INSERT INTO
Posted by warway at 2/24/2004 2:12:55 PM
I have an sp that inserts a record from one table to another based on a parameter that works fine. How can I use a field on an MSAccess form to be the parameter? I can get the sp to run from the form but only to prompt me with the parameter required I want this to be the current record and to do...more >>

Backing up and restoring database to remote server
Posted by Fox at 2/24/2004 2:08:58 PM
Hi, Thanks in advance to anyone who looks at thia. My scenario is simple. I have a new client who I will transfer from one WSP to another WSP. My question is how best to transfer their SQL database? I have Enterprise access to the new host, but not to the old host. The old host is freaky...more >>

osql txt file output problem
Posted by SQL Apprentice at 2/24/2004 2:01:57 PM
Hi, Can you tell me how to get rid off all the empty space in my osql output file (text file)? It always start with a blank space and at the end of each line, there is another 500 blank spaces. I looked at BOL and could not find anything about blank space corrections. The result I get from...more >>

xp_sendmail
Posted by Kevin3NF at 2/24/2004 1:48:10 PM
SQL 2000 sp3 (8.00.760), XPPro exec xp_sendmail=20 @recipients =3D 'kevin3nf@mydomain.com', @Message =3D 'test' When executed, I get: Server: Msg 17985, Level 16, State 1, Line 0 xp_sendmail: Procedure expects parameter @user, which was not supplied According to BOL, there is no @user...more >>

(design question) non-unique clustered index confuses optimizer
Posted by Bob at 2/24/2004 1:45:06 PM
I store a large amount of hierarchal BOM data using a nested set table similar to the one below. It's used for a job shop, so each BOM tree has a top level item which correlates to a particular job. This 'job' exists in a table elsewhere with a corresponding identity JID. Most queries accessin...more >>

Inner Join SP
Posted by Alex Ting at 2/24/2004 1:00:35 PM
Hi everybody, I have two tables to get data from: 1. Users 1. UsersDealer I want a listings of all the users and if the user is in users dealer, a listing of the dealer as well. How can this be done because an inner join will only list all the users that is in the users dealer but i ...more >>

How to calculate 25 working days
Posted by Adrian at 2/24/2004 12:54:59 PM
SQL Server 2000 I want to work out the 25th working day for a table of calendar days. Below is code I have adapted from: http://www.devx.com/gethelpon/10MinuteSolution/16528 to create a table of calendar days, and a two columns indicating if a day is a weekend or holiday. ===============...more >>

How to SELECT with "DISTINCT" on only 1 field?
Posted by Cardinal2B at 2/24/2004 12:26:05 PM
I have a table of 10 million rows as follows: CustomerNumber, Address, StoreNumber, Spending If I use COUNT (DISTINCT Customernumber) I get 3.2 million rows. If I use SELECT DISTINCT CustomerNumber, Address, I get 3.3 million rows This is because addresses changed, original data no well maintain...more >>

Sorry for repeating my Q but I hardly got any response yesterday
Posted by abc NO[at]SPAM helloall.com at 2/24/2004 12:01:43 PM
Hi I asked this yesterday but didn't get any response. Please help me. May be I didn't word it right and I apologize for that. What I am trying to do couldn't be the first time. I will try to ask in parts: I have a table with minutely data i.e. readings for every minute. Create Table TagM...more >>

Parameterized Stored Procedures - Complex Search Conditions
Posted by Kurt Amstutz at 2/24/2004 11:56:06 AM
I have a .NET webform with a multiple select dropdownlist control. Any idea how to create a stored procedure that could utilize the one/many parameters returned from the dropdown list? THE T-SQL Select WHERE search condition clause would have to read something like this: WHERE fieldA = ddParam...more >>

char(9) or char(13) do not work in my query
Posted by SQL Apprentice at 2/24/2004 11:41:23 AM
Hi, I tried to run the following to insert a TAB and RETURN to my select and none of them seem to work. select 'hello!' + CHAR(9) + 'my name is' + CHAR(13) + suser_sname() My result is a one line without any tabs or returns. I ran this code from BOL and it works... Can you tell me what i...more >>

Order by behaviour
Posted by Karl Seguin at 2/24/2004 11:35:45 AM
sorry if this is a double post, it seemed like my first one got marked as invalid or something... Might be out to lunch, but I can't figure why this is being ordered the way it is: SELECT '1' as t UNION ALL SELECT 'A' as t union all SELECT '['as t ORDER BY t I'd expect it to be 1, A,...more >>

number fieds ( scale) problem
Posted by Shahid Saleem at 2/24/2004 11:04:23 AM
Hi all! i have a table in which i am saving serial nos i.e 1 1.1 1.2 1.3 .. .. 1.10 I have created a field with decimal datatype as serialnos decimal(18,2) ( with precision 2) I have put primary key on it , problem is when i put data into table i.e 1.1 it is being saved as 1.10...more >>

Double.NaN and SQL float data type
Posted by Guogang at 2/24/2004 10:59:52 AM
Hi, I use C# to fill a data field of "float" data type in SQL 2000 server. When I use Double.NaN value, there seems to be a problem in "Query Analyzer". I can no longer select the row, an error message: "Numeric value out of range". However, in Enterprise Manager, I can still see the row with ...more >>

SP slower then Query
Posted by Immy at 2/24/2004 10:57:28 AM
Hi all, I've seen these type of problems posted before, but never understood the answers. I have a SP that accepts 3 variables. When the SP is executed, it takes over 5 mins to run. When I execute the exact same SQL from a query window and apply some GO's in it, it executes in 30 seconds. ...more >>

problem using identity column as primary key
Posted by Nikhil Patel at 2/24/2004 10:55:23 AM
Hi, I am thinking of creating an identity column to use it as primary key in my table. But the problem is that once I delete some records, the SQL Server would not reuse the IDs of the deleted records. So there will be holes in the sequence. I know many people use Identity columns to generat...more >>

Insert value from a while loop
Posted by Brandon at 2/24/2004 10:46:07 AM
Hello, Is there a way to use a while loop to update a table with information from table being looped through for instance while (select score from source) < 250 begin insert different_table values (source.column(1), source.column(2)) end I need to INSERT values from the loop ...more >>

can alter table be used to change a column type?
Posted by dk at 2/24/2004 10:44:01 AM
can alter table be used to change a column type?...more >>

Need help with SELECT Query
Posted by Sam at 2/24/2004 10:39:52 AM
Hi, How do I select people who ONLY have apples from the following table? So the the SELECT statement should return 234. UserID -- Fruit 123 -- Apple 123 -- Banana 234 -- Apple 345 -- Kiwi 345 - Banana 345 - Strawberry 456 - Apple 456 - Kiwi ...more >>

how to select the current user and current database name?
Posted by SQL Apprentice at 2/24/2004 10:30:58 AM
Hi, Can you help me write a sql query to show the current user and the current database name? For example, select 'the current user: "' + @currentuser + '" is connected to the "' + @databasename + '" database.' result: the current user "sa" is connected to the "northwind" database. ...more >>

DISTINCT vs GROUP BY
Posted by Miroo_news at 2/24/2004 10:24:56 AM
Hi, I want to get a list of all values in particular column (each value once only in resulting set). I can use: select distinct my_column from my_table or select my_column from my_table group by my_column Is there any difference in efficiency of both methods? Regards, Miroo ...more >>

Odd Order by behaviour
Posted by Karl Seguin at 2/24/2004 10:05:29 AM
Maybe I'm out to lunch, but this doesn't seem right: SELECT '1' as t UNION ALL SELECT 'A' as t UNION ALL SELECT '['as t ORDER BY t returns [, 1, A instead of 1, A, [ which is what I'd expect. Why does [ get pushed to the top? it's ascii value is 91, greater than both that...more >>

unable to execute an update command to a table
Posted by Bruce Gilbert at 2/24/2004 9:58:11 AM
I use the update method on numerous tables, but I get this error "Query cannot be updated because the from clause is not a single simple table". The is nothing specail about this table and in fact it's preety simple. use master create table tblUserLog (Record_No int identity primary key,...more >>

User Functions in batch inserts
Posted by TJoker .NET at 2/24/2004 9:01:25 AM
I'm having some trouble with an Insert statement. Here are my table definifions: table: test_id rowId -> INT - NOT NULL name -> CHAR(10) - NOT NULL date -> DATETIME - NOT NULL uid -> UNIQUEIDENTIFIER - NOT NULL table: test_id_source name -> CHAR(10) I populated the test_id_...more >>

execute SP at same time??
Posted by hngo01 at 2/24/2004 8:48:34 AM
Please refer below stored procedure! If two clients call this SP at the same time, then ProcessByPC field didn't get update by the first client before the second do the select PKID. This will bring in an issue that 2 client select the same record!! How to prevent this happen? Will SQ...more >>

How to get a grapical documentation of my tables ?
Posted by apa57 NO[at]SPAM hotmail.com at 2/24/2004 8:43:47 AM
I wanted to get an overview of my tables, used to do a diagram and print it out. But I really got tired with finding the proper positions and scaling with that. I got close to wonder what the person who implemented the print function for diagrams did think while doing this. So I was wonderi...more >>

How can I improve this code please?
Posted by Trint Smith at 2/24/2004 8:12:23 AM
How can I improve this code please? It sometimes produces this error: "Object reference not set to an instance of an object" When I do this: strSQL = "UPDATE TBL_Items SET" & _ " item_itemnumber = " & PrepareStr(Label6.Text) & _ " ,item_itemcurrentbidp...more >>

How can get random items
Posted by Hoang Duc Chau at 2/24/2004 7:37:52 AM
hi all, i store items in a table (#itemid(int, autonumber), itemname, itemprice) how can i get 5 random items in this table please help me! thanks ...more >>

runtime error -380 invalid property value
Posted by Pnair at 2/24/2004 7:33:38 AM
When I am opening the application ,I am getting this error "runtime error380 invalid proprty value" what can be wrong? How will be I able to fix it?Does this has to do with quoted identifier ? Thanks...more >>

Computing Someone's Age
Posted by paul reed at 2/24/2004 6:21:05 AM
Hello, I have birth date in a table and need to compute someone's age. "DateDiff" with GetDate() along with the "yy" option doesn't help because it doesn't take into account the day of the year. I can't use "dy" because I just get a raw number of days back and can't divide that by "365" becaus...more >>

Date Formatting
Posted by Eric D. at 2/24/2004 5:27:22 AM
Hi, I want to display a date in the following format "yyyy-mm- dd". I don't want any of the trailling time information (ie. h/m/s). TIA, Eric...more >>

How to handle hierarchy processing like this
Posted by belindacur NO[at]SPAM yahoo.com at 2/24/2004 4:46:37 AM
Hello All I have a cost center hierarchy which is like the following: ROOT | |-NODEA | | | |-NODEB | |-NODEC | |-NODED | |-NODEF | |-NODEG | |-NODEH |-NODEI...more >>

SQL AND ASP
Posted by Stephen at 2/24/2004 3:56:07 AM
Hey all I have a number of stored procedures in SQL and am using an ASP to pass in parameters and display the results of the stored procedures in a html table. I need to perform actions like, SUM fields and use ORDER BY commands as well as only displaying certain fields off a results set etc. Is ...more >>

Automating Script Execution
Posted by Ben Reese at 2/24/2004 3:51:05 AM
H I currently have a complex .sql script that produces several result sets detailing the age and status of work in our system I can Set up Query analyser to sent the results to a CSV file that I can then email to my managers I want to automate this process I initially thought That I could set ...more >>

syscacheobjects
Posted by Maryam Teimourian at 2/24/2004 2:06:07 AM
H with exceuting a stored procedure for the first time 2 records are inserted to Master..syscacheobjects but if I execute a stored procedure with ExecProc metod of ADO StoredProcedure in Delphi 5 it inserts 4 records in syscacheobjects.What's the reason thanks...more >>

HowTo merge columns from different tables to one table?
Posted by Andreas Klemt at 2/24/2004 1:41:51 AM
Hello, I have this select from users where userid = 3 select number from usernumber where userid = 5 how can I dynamically merge n columns to one table like this? state1 state2 state3 car1 3 38 57 car2 32 3 1 car3 3 8 ...more >>

HowTo send myid in (1, 2, 3, 4) to a Stored Procedure?
Posted by Andreas Klemt at 2/24/2004 1:16:06 AM
Hello, I have a stored procedure like this Alter Procedure dbo.Test ( @id int ) AS select * from users where userid in @id How can I do it like this exec test '1,2,3,4' so the procedure would do this: Select * from users where userid in (1,2,3,4) Thanks for any help...more >>

Invalid Class string launchimg a DTS
Posted by miky76 NO[at]SPAM tin.it at 2/24/2004 12:40:53 AM
Hi, I get always the error "Invalid Class string launchimg a DTS" when i try to launch a DTS in SQL server from a VB .Net program. tha DTS is made with: - a file text (source) - a connction to a DB in the SQL Server The code I use is Dim package As DTS.Package2Class ...more >>


DevelopmentNow Blog