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 > may 2006 > threads for wednesday may 17

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

Count of rows in conditional basis
Posted by mukesh at 5/17/2006 9:57:25 PM
Hi, I have a table with Seq_No, City, and Customers' Disposition. CREATE TABLE CUSTOMER_DATA( Seq_No bigint IDENTITY(1,1) NOT NULL PRIMARY KEY, City varchar(10), Disposition varchar(10) ) INSERT INTO CUSTOMER_DATA VALUES('DEL','BUSY') INSERT INTO CUSTOMER_DATA VALUES('MUM','FREE')...more >>

turning column header into row
Posted by 22chda NO[at]SPAM gmail.com at 5/17/2006 8:28:27 PM
ID MATH BIO CHEM ENG 1 8 8 8 8 2 7 7 7 7 I want to convert into : SUBJECT VALUE ID MATH 8 1 BIO 8 1 CHEM 8 1 ENG 8 1 MATH 7 2 BIO 7 2 CHEM 7 ...more >>

Just Getting Started
Posted by oneloudogg at 5/17/2006 8:15:28 PM
I have the following columns and data in my table: Col A Col B Col C A1 B1 C1 A1 B2 C2 A1 B3 C3 A2 B1 C4 A2 B2 C5 A3 B3 C6 I would like a query to return my data as follows Col A ...more >>

object_id problem
Posted by Derek Hart at 5/17/2006 7:32:11 PM
I can use the following successfully: SELECT OBJECT_ID('myDB..myTable') but on a linked server I cannot get this working. Is this the right syntax? Should it work? The server name is box. This gives me a syntax error near myDB. Select * From Openquery(box, 'SELECT OBJECT_ID('myDB..myT...more >>

Which query perform faster?
Posted by spirytuspl NO[at]SPAM hotmail.com at 5/17/2006 6:31:50 PM
i have two queries but not sure which one would perform faster, and why. first: select id from students where arrivaldate(year,arrival) = 2000 second: select id from students where arrivaldate > '31/12/1999' and arrivaldate < '1/1/2001' Thank you for your help. ...more >>

Declare Variable As Table
Posted by Taha at 5/17/2006 5:49:21 PM
hi all how can I Declare Variable As Table Like Cursor DECLARE parameter_cursor CURSOR FOR SELECT top 1 c.name, t.name FROM sysobjects o JOIN syscolumns c on c.id = o.id JOIN systypes t on c.xtype = t.xtype WHERE o.name like 'Test' order by o.name, c.colid Tanks ...more >>

Simple SQL query
Posted by jem777 at 5/17/2006 5:26:38 PM
This is very simple... but I can't get it. I have a table which logs every operation of every user. ID_OPERATION OPERATION USER DATETIME A simple example is: 1 LOGIN jack 14/6/2005 23:34:00 2 LOGIN jim 14/6/2005 21:34:00 3 LOGIN billy 14/6/2005 20:34:00 4 ...more >>

SQL Server 2005: a multi-user data aggregation strategy?
Posted by Gary at 5/17/2006 5:21:55 PM
Hi, I have an in-house Windows application, utilizing SQL Server Express 2005 (over OLEDB), which needs to be upgraded to a multi-user paradigm. The solution will require collecting the same kind of data from multiple users in one central, shared database. Due to a sensitive nature of the d...more >>



Set SQL db field to auto insert decimal point
Posted by Simon Gare at 5/17/2006 5:07:14 PM
Hi, I have a page (that I cannot change) that enters currency without a decimal place i.e.. user enters 200 which equals £2.00. I need the SQL db to see these figures and assume that 200 = 2.00 or 1080 = 10.80 etc and add the decimal point. Anyone help? Thanks in advance Simon ...more >>

Linked Server Setup
Posted by Derek Hart at 5/17/2006 4:37:27 PM
EXEC sp_addlinkedserver @server='myServer', @srvproduct='', @provider='SQLOLEDB', @datasrc='myServer', @provstr='DRIVER={SQL Server};SERVER=myServer;UID=sa;PWD=myPassword' I am trying to simply add a linked SQL server that ...more >>

procedural languages vs set based
Posted by Someone Else at 5/17/2006 4:26:56 PM
Hi All, I have a question that might be a little long, but if anyone can take it... I've encountered a sql server database recently that attempts to recreate an object oriented style of programming within SQL. So functions are overloaded by selecting the next function with a couple of extr...more >>

Ad-hoc INSERT of new Identity Value
Posted by Joachim Hofmann at 5/17/2006 4:22:59 PM
Hello, I have a table with a primary key having IDENTITY (ID). In case of an INSERT I want to fill another Column C1 with the new Identity value. How can I achive this? By a Trigger maybe? Thank you very much Joachim...more >>

Aggregate First Not Available?
Posted by MikeV06 at 5/17/2006 3:25:47 PM
The following query runs on Access and returns a result table that removes duplicate account numbers even if they have different names. SELECT AcctNum, First(t.AccountName) AS AccountName FROM tblAcctChart t GROUP BY AcctNum ORDER BY AcctNum; 101 N1 101 N2 101 N3 results in 101 ...more >>

Moving data question
Posted by David Olsen at 5/17/2006 2:46:23 PM
How does one do the following considering that an identical table in Database2 also exists in Database1? INSERT INTO Database1.Table1 SELECT * FROM Database2.Table2 WHERE rows in table2 do not exist in table1 I don't have DDL as I need a general solution for moving data. ...more >>

How delete a empty record by Query?
Posted by Ben at 5/17/2006 1:30:26 PM
I have a temp table like this: TableName: #TempProduct PartNumber Column1 Column2 Column3 Column4 ...... AP-321-00 NULL 0 23 NULL ...... AP-321-01 NULL 5 21 ...more >>

How can I get a count of all records in each table in my DB?
Posted by Greg Toronto at 5/17/2006 12:49:02 PM
Hoping you can help me here.... I have a situation where I need to provide a script that can be run through query analyzer to return the number of records in each table in my DB. I would like it to be dynamic, as the number of tables in the DB changes. Pretty simple query (Select count(...more >>

Update from a number of records
Posted by Adam Warne at 5/17/2006 12:35:02 PM
If I update a record in a table that is joined to another table that holds a number of related records, which record will SQL pick to update from? Some DDL: CREATE TABLE Lookup ( Accnum INT, Value INT ) CREATE TABLE Warehouse ( Accnum INT, Value INT ) INSERT INTO Lookup VALUES (1...more >>

Delete user
Posted by at 5/17/2006 12:25:55 PM
SQL 2005. and SQL Management studio I have a user 'myuser' in a SQL DB 'mydatabase' under security users. When I try to delete him, I get error says DB principal owns schema and cant be dropped. I try to remove his role as DBOwner and it says login name must be specified. (The window above has...more >>

How do I get the ID of the last entry?
Posted by Sam at 5/17/2006 11:55:02 AM
Hi, I need to know the ID of the last entry so that I can use it in a trigger. How do I get the ID of the last INSERT'ed record? Do I use Scope_Identity() for that? -- Thanks, Sam...more >>

full backup and transaction log truncate
Posted by John at 5/17/2006 11:29:09 AM
Hi, I'm confused about how the backup system works in SQL Server. I'm using the BULK LOGGED recovery model, I do regular full backups but my log file is growing very large. BOL says: Full database backup, which backs up the entire database including the transaction log and it also ...more >>

Business Day Calendar table get x days in the past
Posted by _Stephen at 5/17/2006 10:55:59 AM
I have a table of dates and a second column for bit. I need to know the date of X business days ago declare @dateIn datetime, @days int set @datein = '5-17-2006' set @days=5 select A.bdate From BusinessCALendar as A Inner Join BusinessCALendar as B on A.bdate <= B.bdate and...more >>

Linked Servers
Posted by Derek Hart at 5/17/2006 10:02:15 AM
I have 2 different servers, and I wish to join tables from 2 different databases on 2 different servers. I looked into linked servers a little bit. Is this the technology to use? I am connected via a VPN with both servers. Any slick way to do a join like this? Derek ...more >>

Getting most recent row from one-to-many relationship
Posted by Drew at 5/17/2006 9:49:52 AM
I have two tables, Admission and RecordSummary. The Admission table holds one row for each resident at our facility and the RecordSummary table holds one row for each admission the resident has (could be more than 1). They are linked using a Register Number, which is a 6 digit number. The ...more >>

VBscript Shell Script hangs when calling System Stored Proc
Posted by bchodo at 5/17/2006 9:25:02 AM
I'm working on an old system (win2k & SQLServer2K) writing an import routine to periodically process datafiles from even older systems. As part of the process, I want to execute sp_columns on a table to retrieve the column names. But, during the execution of the vbs shell script (written in ...more >>

Trigger that fires Row by Row
Posted by rhaazy NO[at]SPAM gmail.com at 5/17/2006 9:14:38 AM
Hi all, I'm new to this so bare with me. I am using ms sql 2000. I am inserting into tblTest3 4 columns, three of the inserts are done with the INSERT statement as part of a stored procedure, the other insert takes place in a trigger that I need to fire as each Row is inserted. The reason for ...more >>

OpenQuery/ADSI Error Trapping
Posted by GrantV at 5/17/2006 8:54:02 AM
Hello All, I am writing a SQL Stored Proc that will query some information from Active Directory. I have setup the linked server and I can get the OpenQuery to get the information that I require. However, when when I try to run a query that where the ADSI query generates an error I canno...more >>

GUIDs
Posted by Mike Collins at 5/17/2006 8:30:02 AM
I have a question about GUIDs. I am in no way a sql expert, but at our company, our DBA has said we need to use GUIDs for replication. Sometimes we have stand alone databases that we create that we need to resync back to our server. But I read a discussion that seemed to frown on using GUIDs...more >>

In Visual Basic and ADO.NET 2.0: How To Set IDENTITY_INSERT On
Posted by clusardi2k NO[at]SPAM aol.com at 5/17/2006 8:26:40 AM
Hello, From a Visual Basic program how would I turn on IDENTITY_INSERT? Are there any warnings in doing this? What is the right time to do it? How often should I do it? When should I turn it off? Discussion started in microsoft.public.dotnet.languages.vb: http://groups.google.com/grou...more >>

Need help w/Stored Procedure
Posted by cider123 NO[at]SPAM hotmail.com at 5/17/2006 8:05:21 AM
I have a database that could have multiple entries per Site. What I need is the last record added to the database. I'm guessing Group By and Distincts are needed somewhere, but I'm not familiar enough with them and don't have any wizards to help build it--I'm open to wizards, if anyone can rec...more >>

SQL Server Reporting Services
Posted by Pépê at 5/17/2006 8:05:18 AM
Hi, ive been in msdn and doing some tutorials about reporting services, and im a little confused. All i wanted was a way to send to the client email the data from a table in excel format, every friday at six, all automated without having to export manually. I think its possible by this report...more >>

replacing nulls
Posted by VJ at 5/17/2006 8:04:23 AM
I have a string like this select @feed5 = @name+', '+@work_name +', '+isnull( @workedyearfrom, '')+' '+ isnull(@workedyearto, '')+', '+ isnull(@height, '')+'x'+isnull(@width, '')+'x'+isnull(@depth, '')+' '+ @measuretype+' '+'Editions: '+' ' +@edition+.+ Here some of the values will be n...more >>

Troubleshooting a stored procedure
Posted by Sonya at 5/17/2006 7:42:01 AM
I have stored procedure that is timing when ran in a application. When is executed in query analyzer, it takes 43 seconds to complete but if I run just the script it only takes 2 or 3 seconds to complete. We ran a trace and cannot determine where exactly is the problem within the procedure ...more >>

Internal SQL Server error
Posted by Aviad at 5/17/2006 7:12:02 AM
Hi, I executed this query: DECLARE @S1 TABLE ( [Distribution Center] VARCHAR(8000)) INSERT @S1 SELECT [Distribution Center] FROM [my_VIEW] GROUP BY [Distribution Center] DECLARE @S2 TABLE ( [Sub Category] VARCHAR(8000)) INSERT @S2 SELECT [Sub Category] FROM [my_...more >>

stored procedures vs. dll's
Posted by dgator at 5/17/2006 4:50:01 AM
We are looking at moving most of our class libraries (dlls) that are used by our applications (web,web services and console apps) to stored procedures. We feel like it may be better that trying to keep track of whether the app has the appropriate DLL associated with it and to make deployment ...more >>

a small problem
Posted by kishore bondada at 5/17/2006 3:56:01 AM
hi people, my query goes something like this... select a.*,b.*,c.* from table1 a ,table2 b,table3 c where a.col1 = b.col2 and a.col1 = c.col4 for xml auto, elements,base binary64 everything works fine except tht the elements of tables table2,table3 are being added as child/nested nodes....more >>

Invalid Descriptor Index on SQL 2005 sp 1
Posted by David NO[at]SPAM StreamServe at 5/17/2006 3:00:37 AM
We have an app that use ODBC and works on SQL server 2000 but when running the same app and same ODBC driver on 2005 sp 1 we get Invalid Descriptor Index Why? Regards, David ...more >>

sql join table
Posted by wong at 5/17/2006 2:49:01 AM
hi all, have some TSQL question here, hope can get advise fr here ..currently i have 2 tables, and i want the output to be in 1 set: table A grp name subgroup Grp A Jan 2005 Grp A Feb 2005 Grp A Mar 2005 Grp B ...more >>

Getting dynamically values input parameters
Posted by Sjaak at 5/17/2006 2:28:49 AM
I like to print the values of all input parameters dynamically... I get an error: "Must declare the variable '@PARAMETER1'." Is it possible to run sql with variable variable-names??? Here is my test-code CREATE PROCEDURE Test ( @PARAMETER1 char(8), @PARAMETER2 char(4) ) as begin ...more >>

Tracing reads of a column
Posted by fred NO[at]SPAM fredthomas.co.uk at 5/17/2006 2:14:55 AM
Hi, I need to trace where in a program I am working on it read a particular column from a SQL database. Is there a way to use Profiler to do this. IE. If a table (Members) contains ID, Forename, Surname, Age, Sex, Email Can I use profiler to show me each call that includes a SELECT Sex F...more >>

Attach Database Basic Question
Posted by S Chapman at 5/17/2006 2:09:20 AM
When one of our clients tries to attach a database (about 6GB in size) she gets a message saying file size limit exceeded. She is using Sql Server 2000. Is there a limitation on size for Sql Server 2000? I know for MSDE the size can not be more than 2GB. Can you shed any light on the issue p...more >>

Query question
Posted by Jean-Paul Rijnsburger at 5/17/2006 1:46:34 AM
Hello, I could use some help with the following problem: I'm trying to select the following: select max(counter), name, date from table1 group by name, date this works fine, except for the fact that I would like to see the maximum value of the counter and the day that it is reached. T...more >>

Expanson on oprevious T-SQL help
Posted by Peter Newman at 5/17/2006 12:38:01 AM
I have been trying to expand on a query given to me to insert records from one SQL2000 server table to a SQL2005 Server table. The query works like a dream, however i would like to expand it slightly to become an UPDATE query Orig Query INSERT INTO BossData.dbo.BacsHdrYearly se...more >>

Number of weeks in a month
Posted by aa at 5/17/2006 12:00:00 AM
How can i write a Query to find out how many weeks are there in a month, I tried Datediff(wk, startofMonth ,EndOfMont) this is not giving correct output for example : Feb 1998 = 4weeks july 2006 = 6 weeks lara ...more >>

alternate to formula
Posted by Vikram at 5/17/2006 12:00:00 AM
I have a table where one of the field is having formula, where UDF is used. Is there any way by which formula can be removed and any other method is used like trigger, Because we can not have index on a formula based field ...more >>

Logic problem - Please help :-(
Posted by Simon Harvey at 5/17/2006 12:00:00 AM
Hi all, I have a situation that I need some help with as soon as possible. If you’re good at logic puzzles then please help as soon as you have a minute :-) As some of you know I have a situation in which I need to copy data from a table in QuickRes, to an identical table in a new databa...more >>

sp_executesql
Posted by BSGY at 5/17/2006 12:00:00 AM
Hello I want to execute a Sql Transaction. But When I use this command(sp_executesql) , I have to use NVarchar variable that has got a limit that 4000 characters. I need more than 4000. How can i execute my transaction, using sp_executesql. Thanks very much. ...more >>

Deleting a Database
Posted by Yannis Makarounis at 5/17/2006 12:00:00 AM
I am using ADO to execute a DROP DATABASE command. Before that I run some query against the DB to do some checks. However I get the meesage "Cannot drop the database XXX because it is currently in use". If I do not run the query before the DROP works. I have made sure that all connections to t...more >>

SSIS Custom Data Flow Component with Custom UI debuging
Posted by Mirek Endys at 5/17/2006 12:00:00 AM
Hello all, I started to develop my own data flow component with custom UI. SSIS is great technology, but i have a little bit problem with debuging of this. For debuging in design time, is recomended to have opened two instances of VS2005. First instance is the DLL project of my PipelineCom...more >>

Help with a stored procedure or DTS package
Posted by John at 5/17/2006 12:00:00 AM
Can anyone offer me a solution to this , i have a table that hold QI AN Quantity Price Order Refer Area 28 96229392 15 83.98 1 A1 Level 1 28 960004877 55 192.68 2 ...more >>

Progress Indicator
Posted by Jonathan Chong at 5/17/2006 12:00:00 AM
How do I know the percentage done or left when command like DBCC REINDEX or ALTER TABLE on a huge table? Thanks in advance. ...more >>


DevelopmentNow Blog