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 > january 2005 > threads for wednesday january 26

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

Converting NUMBER, DATE and VARCHAR2 database fields from Resultset to variables?
Posted by hamiltonx NO[at]SPAM lycos.com at 1/26/2005 11:11:20 PM
Assume a database (e.g. Oracle) field is declared as a) NUMBER (length=10) b) NUMBER (length=26) c) VARCHAR2 (length=1) d) VARCHAR2 (length=50) e) DATE How do I retrieve the contents from these resultset fields and put it into a (numeric) java resp Date field? For other field types it ...more >>

Attach database
Posted by Venkatesan M at 1/26/2005 10:38:21 PM
Hi folks I have copied a .mdf file from machine1 (without detaching it) Can I attach it to a SQL Server which is running on a different machine (machine2)? If not, is there anyother way to restore the database with the .mdf file (without using the backup)? Thanks in advance. *** Sent via ...more >>

Displaying Auto Sequence Number
Posted by PeterOo at 1/26/2005 8:57:01 PM
I want to write the sql query for displaying sequence number in the result... E.g. SeqNo Col1 Col2 ==== === === 1 aa aa2 2 bb bb2 3 cc cc2 The firlst column SeqNo is not the physical colum...more >>

SQL query to format datetime
Posted by Onnuri at 1/26/2005 8:55:09 PM
Hi, Can I ask you a simple SQL query question? This datetime data type stores records like "1/25/2005 11:37:25 PM". Is there a SQL query to format it like "1/25/2005"? Please let me know. Onnuri ...more >>

permissions gone missing in sysprotects
Posted by Jack Yao at 1/26/2005 8:45:01 PM
Hi all, I have upgarded db from sql 7.0 to sql 2000 and I notice that load of records have gone missing in sysprotects table ( something like from 5000 records down to 60 records only). As a results, permission setting does not appear in objects permission management in Enterprise Manage...more >>

Eliminating rows based on duplicate field values
Posted by Jumping John at 1/26/2005 7:01:02 PM
I need help writing a SQL query that will return the Part_ID, Part_Num, and Part_Rev from a Parts table where I get returned all three values but only the highest Part_Rev for each distinct Part_Num For example, given Part table with the values below: Part_ID Part_Num Part_Rev 1 ...more >>

Using variable within a query
Posted by at 1/26/2005 6:19:06 PM
I want to use a variable inside a query the following way: Declare @Idx as Integer Set @Idx=0 SELECT @Idx = @Idx + Col1, @Idx AS SumSoFar FROM Tbl1 The Error I get for this query is: "A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operati...more >>

Query help
Posted by Doug at 1/26/2005 6:13:40 PM
Hi Group; I am trying to update a field in a table datatype for a SP with code that works fine in Query Analyzer by itself, but not in the full procedure. I need to extract the first few numeric characters ( the number of characters varies by record) from a varchar field before a hyphen '-...more >>



Pls Help!!
Posted by BFG2000 at 1/26/2005 4:36:20 PM
I have a table storing these data COL1 COL2 COL3 ================== CN 2003-06-15 CAR CN 2003-06-16 BUS CN 2003-06-20 BIKE US 2003-07-20 FISH US 2003-07-22 BEER I would like to write a query that extracts the latest COL2...more >>

Find last char index
Posted by Itzik at 1/26/2005 4:29:57 PM
Hi i have column with this values : aa-bb-cc-dd ss-aa dd-aa-ee How can i find last '-' char index i need retrieve this result : dd aa ee Thank you ...more >>

Help in solving queries.......
Posted by Patrick at 1/26/2005 4:27:10 PM
Hi Group I want to divide one column by another column and stored that value into third column. Example : Column A, Column B, Column C I want to divide Column B by Column C and stored that value within Column A Basically Column A is % Column B < Column C ( always ) When I use divi...more >>

Help with SQL Contains clause
Posted by Sanjay Pais at 1/26/2005 4:11:35 PM
why does this Select * from cv_Volunteer_Section where CONTAINS(listingdescription, ' "a/p" OR "a/r" OR "bookkeeper" OR "accounting clerk" ') return this error? Server: Msg 7619, Level 16, State 1, Line 2 The query contained only ignored words. Is there away to prevent the error by editi...more >>

More help with Contains
Posted by Sanjay Pais at 1/26/2005 4:02:24 PM
I had posted an earlier question about the CONTAINS predicate that uses the full text search. The entire process of comparing a column with a keyword variable using the contains predicate was not only taking too long (cursors) but also breaking the stored procedure when noise words were enc...more >>

When to connect; when to disconnect?
Posted by Andreas Tscharner at 1/26/2005 3:29:47 PM
Hello World, I'm quite new to MS SQL Server programming and I am wondering when should I connect and when should I disconnect. At the moment, our application connects to the server at start up, and disconnects when it's shut down. The users normally let it run several hours, maybe even d...more >>

Sending SELECT results to a stored procedure
Posted by Joel Lyons at 1/26/2005 2:52:27 PM
From within a stored procedure, I want to call another stored procedure with the results of a SELECT statement. The SELECT could return multiple rows, so I want to call the other stored procedure once for each row of the result set. For example, ALTER PROCEDURE StoredProc1 (@param1 int...more >>

Array parameters in stored procedures in SQL 2005?
Posted by Morten at 1/26/2005 2:27:16 PM
Hi, I am not sure if I have understood what is happening with the new SQL server 2005. Will we be using .Net classes instead of stored procedures? Will I be able to use an array or list type of parameter for my queries with SQL server 2005? If yes, how would I do this? Thanks, M...more >>

Transactional replication vs. Log shipping
Posted by Andre at 1/26/2005 1:25:07 PM
Can someone explain to me the main differences between these and why you would want to use one over another? Benefits? Downsides? Thanks....more >>

instead of trigger on a UNION view
Posted by Nikhil Patel at 1/26/2005 12:27:13 PM
Hi all, IS it possible to create Instead Of Update, Instead Of Insert and Instead Of Delete triggers on a view that uses UNION keyword? Thanks. ...more >>

ANSI to Unicode(MSSQL) convertions
Posted by Aras Kucinskas at 1/26/2005 12:12:08 PM
Hi, How to convert and transfer ANSI string data from FoxPro table to MS SQL Unicode table. Data in FoxPro are in 1251 codepage (Russian Windows). Now result is like "ÊÎËÜÖÀ ÊÎÌÏÐÅÑÑÎÐÀ 100ìì ".The ODBC driver does not performs the conversion from ANSI to Unicode. Help. ...more >>

Implied If Statements
Posted by Barce5 at 1/26/2005 11:47:01 AM
What would be the best function to do an implied if statement in SQL? ex. if column A = 2 then Column B/Column C otherwise Column B Thanks for your help again!!...more >>

Transactions and SQL
Posted by Richard Wilde at 1/26/2005 11:45:35 AM
I have a stored proc which performs the following delete and insert statements. If any insert statement fails I want the transaction to fail and rollback. Is this the correct approach? Many thanks Rippo BEGIN TRAN delete from dbo.tblLocalised insert into dbo.tblLocalised (lDataTyp...more >>

Foreign Key conflict
Posted by Emma at 1/26/2005 11:45:04 AM
I am importing data from one database to another using DTS. During the importation process, I get the following error message: INSERT statement conflicted with COLUMN FOREIGH KEY constraint. “FK_foot_Gen”. The conflict occurred in database ‘Sales’, table ‘Gen’, column ‘ID’ ...more >>

Schedule query results to file...
Posted by len at 1/26/2005 10:59:03 AM
Hi there. I have many needs. One of these happens to be a requirement to set up a scheduled task which calls a simple stored procedure and then sent the resulting record set to a file - preferably in .csv format. Anybody any ideas how to go about this? My stored proc is very basic (selec...more >>

Reformatting ResultSet
Posted by bigbob at 1/26/2005 10:40:21 AM
I'm using ADO.Net to return a set of records from a SQL Server, which I then process to create a text stream ultimately used as the InnerHTML property of a browser control in a C# project. Please don't ask why I'm doing it that way. I know it's stupid, but customer requirements dictate that it...more >>

ALTER COLUMN
Posted by Vik at 1/26/2005 10:20:15 AM
What is correct syntax to alter a few columns in one query like this: ALTER TABLE dbo.Inventory ALTER COLUMN Fld1 varchar(50) NULL, Fld2 int NULL I get "Incorrect syntax near ',' " error message on this query. Thanks. ...more >>

Pulling stored Procs from a remote db
Posted by Jim McDonald at 1/26/2005 10:07:39 AM
Hi all - I am trying to rebuild a website abandoned by the builder and an SQLServer (I think 2k) db is used under it at the host. I can get at the db by using Access/ODBC with a URL but the migration facility seems only to let me get at the tables. There are about half a dozen SPs referred t...more >>

Does increasing indexes inclease the amount of memory that SQL server uses?
Posted by Sanjay Pais at 1/26/2005 10:01:06 AM
I was surprised by the above statement as I had assumed that SQL Server actually performed better if indexes were used on those colums in tables that are a part of a join, where, or aggregate? I also assumed that Sql Server would use these indexes which actually translated to better perform...more >>

Misleading LEN function
Posted by Forch at 1/26/2005 8:55:01 AM
I almost exploded today: select len(' ') returns 0!!!!!!!!!!!!!!!!!! The equivilant Oracle Function (length) returns 1. Could someone please tell me how to get the number of characters in a varchar field, INCLUDING leading spaces. Thanks! Forch...more >>

Can you SELECT multiple counts?
Posted by Joseph Scalise at 1/26/2005 8:53:04 AM
Is there a way to place a where clause into the select line? I have a query that returns a dataset, within this query I want to count the number of certain values that exist. My example code: SELECT dbo.LeadClient.ClientID, dbo.LeadStatus.LeadStatus, dbo.Accomplish.Accomplish DATEDI...more >>

Help with SP to check and add new user to database
Posted by Mark at 1/26/2005 8:33:34 AM
Hi - I'm new to SPs, and wondered if anyone could help with this SP. It takes a username, email and password - and should register (add) the details to the customer table. But first, I would like it to check if the email address already exists in the DB - by performing the first SELECT statem...more >>

Ramifications of running SQL Server 2000 and 2005 on the same mach
Posted by UncleSam89 at 1/26/2005 8:23:03 AM
I am wondering which problems to expect when running both 2000 and 2005 on the same machine? Could they communicate to one another? If I can use extended stored procedures written for 2000non 2005?...more >>

Adding another step to the following
Posted by scuba79 at 1/26/2005 8:07:04 AM
I have the following statement : CONVERT(INT,( CONVERT (VARCHAR(4), SUBSTRING (terminatingcountrycode, PATINDEX('%[^0]%', TerminatingCountryCode), LEN(TerminatingCountryCode)))+ CONVERT (VARCHAR(4), SUBSTRING(TerminatingIDDDCityCode, PATINDEX('%[^0]%', TerminatingIDDDCityCode), LEN(Terminati...more >>

Determining Last modification date
Posted by Dave at 1/26/2005 8:00:14 AM
I would like to loop through or query all the tables in my database and determine their last modification date. Is there an easy way? Thanks, Dave ...more >>

Table Deafinitions
Posted by Peter Newman at 1/26/2005 7:59:03 AM
does anybody know of query that will return the table def's for a given Table ie FieldName, FieldType, Length Allow nulls...more >>

Using sql script files in ADO
Posted by Tod at 1/26/2005 7:44:27 AM
Here is my newbie question o' the day: So far my SQL queries have been only a few lines. I write some VB code to send the SQL to the database and retrieve the data in an ADO Recordset. But now I have a query that is very long, and I wonder if there is some alternative way to send that que...more >>

Convert text to number
Posted by Barce5 at 1/26/2005 7:43:02 AM
Is there any way to convert a text field to a number field and drop any data that has an alpha character in it? I am able to override the message in Access but I am not sure if you can in SQL. For ex. "1234AB" Don't want this data "123456" Want this data Thanks, Lisa...more >>

Syntax checker
Posted by idoek at 1/26/2005 7:01:06 AM
I believe there is a bug with the syntax checker of SQL Enterprise Server 2000 (Version 8.0 with service pack 3a) regarding the check of variables declaration. It only checks if a declare statement for variable with the same name appear more than once without checking the logic of the trigger....more >>

Control-of-flow Temp Tables
Posted by Wendy at 1/26/2005 6:51:02 AM
My question is: I am having problems with a recompiling stored procedure and am trying to pinpoint where it is recompiling. I know that it is not recommended to use temp tables in control-of-flow statements but............if you do and the creating of the temp table does not fit the IF...more >>

Convert char(24) to smalldatetime
Posted by Joe K. at 1/26/2005 6:05:06 AM
I have a table that has a field with sample time that is set up as char(24). I would like to write a SELECT statement converts char(24) to smalldatetime format. Table A Counterdatetime char(24) Please help me resolve this issue. Thank You, ...more >>

Intermittent ORDER BY not functionning
Posted by David Parenteau at 1/26/2005 5:47:31 AM
Hi! I have this query running well, except that when executing some times, the result change and doesn't start with the urgence24 column order as requested!!! It's really strange. Does somenone can help me or tell me where to find? Does the SELECT INTO with temporary table can make a ...more >>

Unions with ntext field?
Posted by Pascal at 1/26/2005 2:39:53 AM
Hi all, I have the following SQL script: SELECT field FROM table UNION SELECT CAST ('' as ntext) as field FROM table 'field' is of ntext type. SQL Server returns the following error: The text, ntext, or image data type cannot be selected as DISTINCT Can I overcome this pro...more >>

Why ADO.NET?
Posted by Brian at 1/26/2005 1:03:03 AM
I would like to insert many millions of records into a database. The task led me to ADO, which Microsoft flaunts heavily. I've just looked at ADO superficially. But I can't see many differences between ADO and ODBC. All of the ADO examples use SQL syntax. Does ADO allow for massive reco...more >>


DevelopmentNow Blog