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 > november 2006 > threads for tuesday november 7

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

Select one record per category from many ?
Posted by +Bob+ at 11/7/2006 11:00:03 PM
I have a table that contains records in various categories. Let's call the possible categories A, B, C, D, E, etc. I need to pull just a list of the categories that are in the table. On a particular day there may be hundreds of records but only in categories A, D, and E. I don't want all the ...more >>


diff between function and stored proc
Posted by vipin at 11/7/2006 8:16:59 PM
hi, can any body tell me what is the diff. between function and stored proc.what is usefull to create my application good. ...more >>

NEED Joins or any other better option
Posted by xgopi at 11/7/2006 7:44:01 PM
HI, The existing query which is biult is an asp app is as follows select ID,Name from [view_ReportTracK] with (NOLOCK) where ( (id in (select id from view_orderchanges with (NOLOCK) where ODate >= convert(datetime, '1/1/2005') and ODate < (convert(datetime, '2/1/2005') + 1))) ...more >>

str() and equality
Posted by Lloyd A. Duke at 11/7/2006 7:38:07 PM
Can someone tell me why this is always not equal? And how to convert to be equal? declare @str nvarchar(3) set @str = '123' if (@str = str(123) ) select 'equals' = str(123) else select 'not equals' = str(123) ????...more >>

very large table
Posted by eladla at 11/7/2006 5:53:01 PM
Hi! I have a table with about 18M rows. Every DDL or DML or select I run on the table takes forever. Are there any specific table settings or something that I can use to speed things up? I have tuned my SQLs the best that I could and they seem more or less optimal at this point. Any suggest...more >>

differences between temporary table approach
Posted by c.m. at 11/7/2006 5:26:04 PM
Hi all, I'm developing a stored procedure that uses temporary tables to store support data to reuse in different part of the procedure. I frequently use a table stored in tempdb and I've always had good performances, but I know that I can also use different approaches and I want to under...more >>

Use of WITH (NOLOCK) in select?
Posted by Stephane at 11/7/2006 4:54:01 PM
Hi, I just finished reading this article about WITH(NOLOCK) here http://www.sql-server-performance.com/lock_contention_tamed_article.asp I was wondering what others think? Is it a good idea to use that? I ask this because I have some tables which are only used as data warehouse to creat...more >>

Use of indexed views or not?
Posted by Stephane at 11/7/2006 4:34:02 PM
Hi, I've been using views to simplify my queries. Since I discovered I can put indexes on them, I started to use this and it improved the performance a lot, even though I already have indexes on several field in their table. I have complex queries on tables with millions of data. Without i...more >>



Error converting data type varchar to numeric.
Posted by MittyKom at 11/7/2006 4:02:01 PM
Hi All I am getting an 'Error converting data type varchar to numeric' when i run a query to select all the records and adding an additional column 'Comm' which is an Amonut column copy but, inserts a 'DataError' message whereever the amount is a zero. I would like to keep the table struct...more >>

To write SPs, or not to write SPs, that is the question....
Posted by Kevin S. Goff at 11/7/2006 3:42:37 PM
Hi, all... I'm involved in a debate with someone over the benefits and pitfalls of stored procedures, versus other methods [mainly, SQL pass-through]. [yes, i know, this has been debated for years] As an applications developer, I use SPs for most database operations, and always use them as ...more >>

What's the best way to implement min4(v1, v2, v3, v4) in SQL 2000?
Posted by nkw at 11/7/2006 3:28:01 PM
I want to have a function to return the minimum of 4 (or N) parameters. Any good way to implement it? For example, dbo.min4(23, 3, 54, 5) return 3....more >>

UNIQUE CONSTRAINT question
Posted by Keith G Hicks at 11/7/2006 3:24:45 PM
I've always created numeric PK's using idenity columns where necessary in tables. I'm also careful to index columns that are used in joins, sorts, etc. But something just occurred to me. If I have a table Custs with PK of CustID Identity 1,1 unique constriant, is it also indexed? or do I need to ...more >>

Windows User Name
Posted by Dazzle at 11/7/2006 2:47:01 PM
Hi, When I log into Windows XP I use my name 'Shelley' I am trying to set a default value in a field in a table (SQL 2005) to be the value 'Shelley' or another persons name if they are logged in. I have tried suser_sname result (server name\admin) system_user result: (server name\admin) user...more >>

Query Help
Posted by JM at 11/7/2006 2:14:05 PM
I can't figure out how to get a list of all users with their last login. Does this require a sub query? Self join? Distinct? This has my brain exploding. Table Users: UserId(PK), UserName dnowitski,Dirk Nowitski mmodono,Mike Modono snash,Steve Nash Table Logins: UserId (FK), UserName...more >>

Distinct Column
Posted by philip260 NO[at]SPAM gmail.com at 11/7/2006 1:30:01 PM
Im trying to run a query that will pull distinct data not for the entire select query but for a single column. Here is my sql statement below. Why is it not working? It is probably something stupid. Thanks for your help in advance SELECT Count(MastrQualityTbl.[WORK NUMBER]) AS [TOTAL WORK RECE...more >>

How do I alter table to add new columns?
Posted by Learner at 11/7/2006 1:12:42 PM
Hi, I have made a sql to alter a table if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Temp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) Begin alter table Temp add LastUpdatedBy nvarchar(50), LastUpdatedDate datetime End But this script is good for first tim...more >>

SSIS AWDataWarehouseRefresh Package Sample
Posted by iano at 11/7/2006 12:30:37 PM
I just ran the package using BIDS and it failed with some connection errors: [Execute SQL Task] Error: Failed to acquire connection "localhost.master". Connection may not be configured correctly or you may not have the right permissions on this connection. Data Source=(local);Initial Catal...more >>

Code will not compile in 2005
Posted by Hulicat at 11/7/2006 12:27:24 PM
I can compile on a 2K box, however; in 2005 I get the following error: Msg 4104, Level 16, State 1, Procedure gsp_Volunteer_Search_ByRegions, Line 22 The multi-part identifier "dboGroup_Region.RegionId" could not be bound. See anything in this that should be changed: CREA...more >>

SMO - How to connect and execute a script on a different server.
Posted by JM at 11/7/2006 12:16:02 PM
How do you connect to a different SQL Server/Instance, execute a query and get resultset from that server using TSQLin SQL Server 2005 ? Earilier DMO was used for this. Thanks ...more >>

Set default for null values in unmatched rows of left join
Posted by Nathan at 11/7/2006 12:13:02 PM
Is there a way to set a default value for a particular column in unmatched rows that would normally return null? Left Join ...more >>

Error #-2147199229 without description
Posted by granzow NO[at]SPAM gmx.de at 11/7/2006 12:12:04 PM
ExecuteImmediate with the SQLDMO sometimes returns an error with err.number -2147199229, while err.description is empty (nullstring). The command appears to be correct, since a repeated execution of the same command usually succeeds. I wonder what kind of error that is. Any ideas? Joachim Gra...more >>

Insert rows to #temp table from ado.net table - best practice?
Posted by Rich at 11/7/2006 11:46:02 AM
I need to add rows to a #temp table that I create from a dataAdapeter.SelectCommand ... Create Table #temp(col1 int, col2 int) While I have the connection open that the #temp table was created on - it remains alive. I have data in an ado.net table (in memory) that I need to transfer that d...more >>

Missed Inspections During the last period.
Posted by Jay Balapa at 11/7/2006 10:27:10 AM
Hello, I have three tables- TBLINSPECTION with the following fields- BARCODE ITEMTYPE PASS DATEINSPECTED 1000 x YES 01/12/2006 1001 x YES 02/12/2004 1002 x YES 03/12/2006 1003 y ...more >>

Appending data after comparison against existing data
Posted by br at 11/7/2006 9:04:01 AM
Hello: I currently have a query that compares the results of a bulk upload to data already loaded into a SQL Server table, tblCDR. Any data that does not currently exist in the table tblCDR is then appended into tblCDR. I am using DTS and Temp tables to accomplish this task. However, I...more >>

Constraint order
Posted by Cyrille Armand at 11/7/2006 8:49:01 AM
Hi I have a program that transfers data from one db to another. I need to transfer them in order so I don't have referencial integrity problems, in other words a master table must be transfered before its child. Is there a stored proc or view that allows me to get that order? Thks...more >>

SQL table copied (or linked) to MS Access
Posted by TomH at 11/7/2006 7:35:02 AM
I have a MS SQL server table that I would like copied (or linked) to MS Access. I've tried doing a 'SELECT * INTO accesstable IN c:\mydatabase.mdb FROM sqltable', but I only get error messages (Error in destination table specification. unable to parse query text). I can copy the table if I lea...more >>

Import To SQL From excel
Posted by amjad at 11/7/2006 5:12:02 AM
I have tried to import from a spreadsheet into SQL an I get this error message Error 0xc00470fe: Data Flow Task: The product Level is insufficient for the componet ...more >>

xp_cmdshell not getting executed for FTP.
Posted by Archana at 11/7/2006 4:35:01 AM
Hi all, I want to get list of directories of ftp folder in stored procedure. So i am trying to use xp_cmdshell. command which i am trying to get list of file is as below. exec xp_cmdshell 'FTP.exe testftp test pwd dir /users//test/ quit '; Here hostname is testftp username is test ...more >>

Create Database...For Attach problem with dbowner
Posted by Catadmin at 11/7/2006 4:12:01 AM
All, Due to a problem with sp_fix_user_logins not wanting to update a SQL Server login that is set as DBO on a database, when I restore my production DB to our Dev/Test/QC environments, I change the dbowner to a domain account, then run through the logins fix. This part works fine. Howeve...more >>

How to cause a guaranteed lock?
Posted by Evil Overlord at 11/7/2006 3:38:07 AM
It may seem strange to WANT to cause a lock but I am developing a perl script to analyse locking issues over a given time period. I need to cause a database lock at will on a SQL Server 2000 database in order to test this perl script is working. Can anyone think of a simple method of causing...more >>

Incorporating a day number in backup name
Posted by hals_left at 11/7/2006 3:19:13 AM
Hi how can I add the numbers 1-5 to this to correspond to the days monday through friday. Thanks SET @BackupFile = N'C:\Backups\MyBackup.bak' ...more >>

UK Postcode Validation on SP Inputs
Posted by planetmatt at 11/7/2006 3:10:09 AM
Is there a way to easily validate a SP variable that will be used to insert a UK postcode into the database. I have a regular expression for the input mask but dont know how to apply it to the variable. ...more >>

If conn_updated_any_record Then.....
Posted by lovely_angel_for_you NO[at]SPAM yahoo.com at 11/7/2006 1:40:39 AM
Hi, I have the following sql query being executed. StrSQL = "" StrSQL = StrSQL & "Update MyTable Set " StrSQL = StrSQL & "Field_1=1, " StrSQL = StrSQL & "Field_2='" & text1.text & "' " StrSQL = StrSQL & "WHERE ID=" & idUpdate Conn.Execute StrSQL After the query is executed, I want to k...more >>

Multiple Applications updating same tables
Posted by C at 11/7/2006 1:39:02 AM
Hi, I am about to develop an ASP.NET app that updates tables in an existing SQL Server Database. These same records will be updated by another application. In terms of updates of the same records at the same time in both applications what do I need to consider? Thanks in Advance....more >>

Last Record
Posted by Sundara Murthy at 11/7/2006 1:26:02 AM
Hi Experts, How to take the last record in the table1 Table1 Item_code Date Qty 111 20061020 12:00 200 111 20061021 13:00 150 111 20061023 14:00 100 111 20061023 15:00 75 112 20061020 12:00 300 112 ...more >>

DateTime Format
Posted by k.karthikit NO[at]SPAM gmail.com at 11/7/2006 12:17:44 AM
Hello All, Is it possible to store the date as ' 02 - Apr - 2006 ' in the SQL datetime field? If it is please tell how to do. Thanks, karthick ...more >>

Why Dynamic Queries Work like that ?
Posted by Bassam at 11/7/2006 12:00:00 AM
Hello, I wonder why SQL Server does not accept a syntax like this in dynamic SQL, i mean why can't MS simply add this simple method, =========== Declare @Wherestr varchar(100) SET @Wherestr=' Column2=100' SELECT a.Column1 , a.Column2 , b.Column3 FROM Table1 a Join Table2 b on a..ID...more >>

Decimal Comma vs Decimal Point
Posted by Bart Steur at 11/7/2006 12:00:00 AM
Hello, I want to insert a Single/Float type value into a table using the following SQL statement. I'm executing this from a VB6 app using ADO 2.7. myValue = "0.5074655" (Entered by the user into a textbox) strSQL = "INSERT INTO myTable VALUES (1,'1A',csng(myValue)) conn.Execute stqSQL T...more >>

SELECT ... WHERE .. IN @DynamicList ?
Posted by Rickard at 11/7/2006 12:00:00 AM
I have the need for a query that takes as a parameter a number of valid values for a column, say 1,2 and 3. What I want to do is then to have a query like SELECT col1,col2 FROM mytable WHERE col3 IN (1,2,3) but the problem is the values 1,2 and 3 must be specified in a parameter and the numbe...more >>

Performance degrade after using NOLOCK ?
Posted by Roshan N.A. Jayalath at 11/7/2006 12:00:00 AM
Hi all, We experienced some deadlocks in our servers and to resolve those we used nolock query hints in some of our select statements. Afterwards we are experiencing "There is insufficient system memory to run this query." errors for queries which previously ran well. These queries also doe...more >>


DevelopmentNow Blog