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 2005 > threads for wednesday november 16

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

Result of a transaction???
Posted by Chakkaradeep at 11/16/2005 10:26:04 PM
hi all, am new to SQL Server Programming, i want to get the result of a transaction whether successful or not, so that i can commit transaction continue to the next transaction, how could i do this in SQL Server?... regards, C.C.Chakkaradeep...more >>

FK Constraint
Posted by vanitha at 11/16/2005 9:49:02 PM
Hi, My Master table structure CREATE TABLE [dbo].[GR_CHANNEL_M] ( [CHANNELNO] [varchar] (50) NOT NULL , [SERVICE] [varchar] (50) NOT NULL , [IVR] [varchar] (50) NOT NULL CONSTRAINT [GR_CHANNEL_M_PK] PRIMARY KEY CLUSTERED ([IVR],[CHANNELNO]), [OPTIONAL1] [varchar] (50) NULL , ...more >>

add another column to sproc output
Posted by Hassan at 11/16/2005 8:46:49 PM
Say i have sproc that return rows with x columns. Say I now want to add another column to it. For eg: Say I am running sp_who2 But now Say i want to add a getdate column to it and i want to do something like Select getdate() + exec sp_who2 ...more >>

T-sql - importing Excel(.xls) files
Posted by bill_morgan at 11/16/2005 7:09:02 PM
Friends, We have over 250 Excel(.xls) files to import into a Sql Server db table. We have tested the T-sql import procedure, and it works fine. However, the import procedure is designed to fail if any of the 250 .xls files are missing. Consequently, we want to ensure that all the .xls file...more >>

Indexed view is not used in the query.
Posted by myao2005 NO[at]SPAM gmail.com at 11/16/2005 5:33:06 PM
Hi, I have created a indexed view with the clustered index as well as some other indexes. When I issued the following query, I could see from the execution plan that sql was executed on the view itself: SELECT mls_num FROM MLS_House_InfoNeed WHERE MLS_House_InfoNeed.ss_status=1 AND MLS_Ho...more >>

Using a integer indicies on the Order By clause of a ROW_NUMBER OV
Posted by gav at 11/16/2005 3:48:16 PM
im having trouble trying to dynamically sort the result set of a ROW_NUMBER function in SQL Server 2005 (9.0.1399). If I use a input param in this clause, nothing is sorted (where @SortBy is an int): ROW_NUMBER() OVER (ORDER BY @SortBy ASC) AS RowNumber if i use a number direct, ROW_N...more >>

DDL in a Transaction?
Posted by Snake at 11/16/2005 3:37:20 PM
Can someone point me to a doc on including DDL in a transaction? I have never seen this and I need to understand it. Thanks, Michael...more >>

GROUP BY or what else?
Posted by Just D. at 11/16/2005 3:31:05 PM
Hi All, I have a set very complicated tables and queries. This is a significantly simplified schema and one of the subqueries should do the following: This is an example of the table. Table tblResponses ---------------------------------------- RespID, PK, int, NOT NULL UserID int, not...more >>



Select and join Data from two databases in SQL 2000
Posted by gv at 11/16/2005 3:28:11 PM
Hi all, The query below works fine pulling records from 2 different SQL 2000 Databases that had a ERCP and a EUS procedure. I need to just pull those that had a EUS within 1 month PRIOR TO their ERCP. Can someone please help. Sample data is below IF EXISTS (SELECT NAME FROM SYSOBJECTS WHE...more >>

System Stored Procedure for validating a stored procedure.
Posted by Sudhir Darbha at 11/16/2005 2:40:07 PM
Hi all, Is there any System Stored Procedure to perform a validation on all the user-defined sprocs. The result should give me a list of sproc names that are invalid. When I say "Invalid", it means that the sproc contains code that referes invalid objects names (tables or columns). Th...more >>

Query Analyzer, Database dropdown
Posted by S at 11/16/2005 2:32:11 PM
Ok. Whenever I have to switch to a different database in my DEV server, if I click the dropdown box, it takes for ever to show the list of databases on that server.I tried few things, but didn't work. I truncated the Log files, Shrink database & log files. Any clues how this can be rectified. ...more >>

How to find row value not present
Posted by vinod at 11/16/2005 2:28:35 PM
Hi All, I have table with 2 cols 1)ObjectName 2)Owner (omlitted other cols for simplicity) ObjectName Owner obj1 own1 obj1 own2 obj2 own1 obj2 own2 obj3 own1 ...more >>

"select rows @start through @end" -- how to do it?
Posted by Jesse at 11/16/2005 2:15:19 PM
Thought I'd post the whole problem I'm trying to solve -- seems like it's common enough that there must be a "normal" way to do this. I want to say "select the top 2000 rows, starting at row 15000, from myTable order by foo". I know I could use SELECT TOP 17000... to limit the number of row...more >>

"select top @numRows" is an error?
Posted by Jesse at 11/16/2005 2:09:20 PM
In my user-defined function, I had this: DECLARE myCur CURSOR LOCAL SCROLL READ_ONLY FOR SELECT TOP 5 foo, bar FROM foobar; So far, so good. I tried to replace it with: DECLARE @numRows INTEGER SET @numRows = 5 DECLARE myCur CURSOR LOCAL SCROLL READ_ONLY FOR SELECT TOP @numRows ...more >>

Why is this query wiping out my data when ther isn't a match?
Posted by Alpha at 11/16/2005 2:07:53 PM
I am updating data in sql by reading in from an Access DB. However, if it will wipe out the data in VehDetail.LastOdometerDate column if there is no match found for d_RemoteName = VehDetail.VName. Can someone help me with how to correct this problem? Thanks, Alpha UPDATE VehDetail SET Ve...more >>

From cursor to table variable?
Posted by Jesse at 11/16/2005 1:55:00 PM
Short version: I'm trying to write a UDF that does this: INSERT INTO @resultTable (intColumn, textColumn) FETCH NEXT FROM myCursor Is that possible? Or do I need to fetch into local variables, then insert? (I'd rather not, because you can't have a local variable of type "text".) Thanks...more >>

deleted all records strangely
Posted by JY at 11/16/2005 1:30:56 PM
we have two tables: TIMECARDBATCH and TIMECARD. TIMECARD has a foreign key to TIMECARDBATCH. User can only delete one row from TIMECARDBATCH at a time. We have a delete trigger on TIMECARDBATCH which deletes corresponding records from TIMECARD. In our production environment at one time all r...more >>

Calling into a C# DLL from T-SQL
Posted by Charlie NO[at]SPAM CBFC at 11/16/2005 1:24:14 PM
Hi: I have an encryption DLL written in C#. Is there a way I can call into it for encrypting and decrypting data during a T-SQL query? Thanks, Charlie ...more >>

Violation of PRIMARY KEY constraint with SELECT statement!?
Posted by Mike Bromwich at 11/16/2005 1:06:44 PM
Hi I'm trying to diagnose an intermittent and strange problem - a primary key violation reported when executing a simple select statement. The SQL is: SELECT TOP 1 [B].[WebStateKey],[B].[WebStateVariableName],[B].[WebStateVariableValue] FROM [WebStateData] B WHERE (B.WebStateKey=@IN_WebS...more >>

Syntax error
Posted by Morten Snedker at 11/16/2005 12:59:09 PM
I get an "Incorrect syntax near ')' on SELECT @tFaerdigAntal=SUM(FaerdigAntal) FROM (SELECT DISTINCT ProduktionNavn, FaerdigAntal FROM vProduktion WHERE @where) t If I remove "WHERE @where" it works fine. @where contains: SET @where='DriftstedID=1' What am I doing wrong? Regards /Snedk...more >>

Insert trigger changing record
Posted by Hugo Madureira at 11/16/2005 12:47:51 PM
Hello all! I want to create an insert trigger to change some fields of the inserted record. I want to put in two fields the system date and system time. When I try to update Inserte table I get an error telling me I cannot update inserted tables. Can anyone give me a hand on this? -- ...more >>

Get Int part of numeric exp
Posted by HP at 11/16/2005 12:29:44 PM
Is there any function in SQL to get the integer part of a numeric expression? eg. a = 12345.67 I want to get a = 12345 Thanks!...more >>

network usage on varchar parameters
Posted by wolfing1 NO[at]SPAM gmail.com at 11/16/2005 12:16:12 PM
Don't know if this should go here or in a vb group but... If I define a stored procedure parameter as varchar(300), and the vb program calls the stored procedure but the vb parameter defined as string has, say, 6 chars, how much is actually passed to the sql server? 300 chars or 6? I'm concerne...more >>

Case Statement in Stored Procedure ?
Posted by AkAlan at 11/16/2005 11:48:21 AM
I am converting IIF statements from an Access Query into a Stored Procedure and was doing ok until I got to this one which is a bit more complicated: CASE WHEN [Field1] = 1 THEN 0 ELSE [Field2] + [Field3] -[Field4] / [Field5] END All fields are valid boleen fields I have tried putting p...more >>

Column alias in select statement - efficient?
Posted by Gert Conradie at 11/16/2005 11:45:55 AM
Is a column alias in a "select" statement more efficient? (statement parsing etc...) Thanks, gert ...more >>

DBO
Posted by docsql at 11/16/2005 11:13:23 AM
On our dev server the app developers have been granted dbo access to their individual databases. They do not have sa rights on the Dev SQL Server. The problem is that when the app developers create new objects, they are the owners. For example, user1.testtable. Since user1 has dbo access, i...more >>

Can SQL Server Make A call to a Windows Service?
Posted by Roger Twomey at 11/16/2005 11:10:44 AM
I have an application which needs to be able to use our local SQL server database to get data (go figure, what else would it do right?). When the data being sought is NOT in the database I need to be able to connect to a MySQL database which is located... oh maybe 1500km. from here. I use a...more >>

insert comma delimited string
Posted by shank at 11/16/2005 10:49:57 AM
I have the following SP. The string coming in is show below. How do I parse that string and insert into my table? thanks! Incoming data....... @PID = 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 @SK = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 @IDD = 121...more >>

Joins issue
Posted by Steven Scaife at 11/16/2005 10:46:25 AM
Sorry if this is the wrong group but.. I have a query that still has a few minor issues the main problem i had with nulls is sorted however i am joining 5 tables together and if a row doesnt exist in a table i dont get a row at all, i have a table that i know a record always exists in and i am...more >>

Scan data into SQL Server 2000?
Posted by John at 11/16/2005 10:43:15 AM
Hello. Please forgive me if this post is not relative to this newsgroup and if someone could advise which group I should post this in I would appreciate. Does anyone know or have any ideas on recommended software or methods in capturing data from scanned paper documents into a SQL Server 2...more >>

Query for database name
Posted by HP at 11/16/2005 10:43:09 AM
Is there a way i can query for the database name? thanks!...more >>

copyind data and indexes
Posted by Jaime Lucci at 11/16/2005 10:41:57 AM
Hi everyone! How can I do to copy the data and the indexes from an existing table on a database to a new table in another database? I've tried with select * into base1.table1 from base2.table2, but it only copy the data and not the indexes. Can I do it by code? I'm trying to avoid the use...more >>

Error while creating a new view
Posted by moonflower at 11/16/2005 10:35:24 AM
I get the message "There is already an object named 'xxx' in the database. I was creating a new view and had an error on it. I fixed the error and resubmitted the create view and I received this error message. I tried to find the view but it was not there. It must have created an object with tha...more >>

Create Query
Posted by bluesrock12000 at 11/16/2005 10:15:50 AM
I have a table where the first column has several numbers in numerous formats. I would like to sort by using the first two digits. (15) This is what I have right now. select * FROM GL1400 WHERE GL_ACCT '15'; GO Obviosuly in the 300k rows there are a few '15' that are in the middle of ...more >>

How to Write Image Data type
Posted by vinoth NO[at]SPAM gsdindia.com at 11/16/2005 9:50:27 AM
Hi, I want to write Image data type of SQL to Database. I have the following code to write into database. Its throwing following Excepetion. Exception : Must declare a scalar Variable @metaInfo This is my Code: public void SetMetaInfo(string siteUrl,string RURL,object MetaInfo) { ...more >>

PATINDEX, LIKE and escaping
Posted by Daniel Pratt at 11/16/2005 9:18:08 AM
Hi, I need to scan some character data for the presence of certain "invalid" characters. The characters I need to scan for are !@#$%^&*()_+={}[]|\:;"<>,/? The PATINDEX function works so long as the ] character is omitted, e.g. set @s = 'foo$' select patindex('%[!@#$%^&*()_+={}[...more >>

query execution plan
Posted by Jason at 11/16/2005 9:13:20 AM
Hi, Could somebody explain me about the query execution plan in the sql analyzer? When i look at the execution plan i see several icons displaying 100% or sometimes a higher percentage. Should all icons be 0% or does it depends on the icon?...more >>

Management Studio not showing cluster running
Posted by Andre at 11/16/2005 9:10:36 AM
When I register my clustered servers in Management Studio the green arrow does not show up. Can anyone explain this?...more >>

Query: select first two highest salary in each department?
Posted by Caspy at 11/16/2005 8:56:49 AM
I need a query to get the first two highest salary in each department. Efficiency is a main concern since the table is about half million records. Please give me some suggestion. Thanks, Caspy ...more >>

Single row for a maximum value
Posted by sujoyp at 11/16/2005 7:59:10 AM
Hi : We want to return the maximum date from a given query for a series of rows for different dates. for example the result set will have the foll.: col1 col2 5 08/2005 5 09/2005 6 08/2005 6 08/2005 Is there a function in T-SQ...more >>

Proper Case
Posted by xsluser at 11/16/2005 7:45:09 AM
Is there any way to convert to Proper Case in SQL Server? for lower case we have LOWER and for upper case we have UPPER like that is there any thing for proper case? if not how can we do this?...more >>

removing duplicate rows
Posted by Amit at 11/16/2005 7:33:14 AM
I am not able to figure out a script that removes duplicates if for the same SSNs, the startdate and a code is the same. sample data SSN startdate code 123456789 11-12-1980 2540 456789123 14-5-1965 1236 123456789 02-09-1980 ...more >>

Complicated (maybe)
Posted by d4 at 11/16/2005 6:33:45 AM
Server Type ------ ------ S1 A S2 A S3 B S4 B S5 C S6-... D I need to randomly pick one server that is type A, one that is type B, one that is type C, and 5 that are type D (Of course there is more than 2 type A's, etc th...more >>

SQL Query Triggers & Joins
Posted by scullpa NO[at]SPAM gmail.com at 11/16/2005 6:19:13 AM
Hello - I'm trying to create a trigger that will update two fields in my APATR named table upon insertion or modification. Let me preface this to state that we are posting invoices and for each invoice there is at least two rows for general ledger purposes. One that has a debit value (expense ...more >>

stored procedure open new connection implicitly
Posted by Roy at 11/16/2005 5:20:03 AM
I use OLE DB to call a series of stored procedures to add records to database tables within one transaction. I got the following errors: Description: Cannot create new connection because in manual or distributed transaction mode. Source Description: Microsoft OLE DB Provider for SQL Server ...more >>

How to use "delete" query for more than two tables?
Posted by Chakkaradeep at 11/16/2005 5:12:09 AM
hi all, i need to perform a operation where in to delete tableA,tableB based on some conditions, here is the query, ***********************QUERY************************** delete from tblSS_ShiftPeriodStamps,tblSS_ShiftStamps where tblSS_ShiftPeriodStamps.StartTime <= @PurgeTime and tbl...more >>

BULK INSERT - A general question
Posted by rudolf.ball NO[at]SPAM asfinag.at at 11/16/2005 4:54:46 AM
Hi NG, I am working with BULK INSERT`s have some general questions about BULK INSERT: - how does a BULK INSERT really works within the database? Why is it faster? - why can I only pass a file to a BULK INSERT? - are there ways to tune the BULK INSERT performance? Thank you very much ...more >>

help with a query
Posted by EdwinSlyfingster at 11/16/2005 4:30:02 AM
Hello..I need help Surporse I have a table TBRelation with 4 columns A1,B1,A2,B2 all are int. this table has two relation with a table called TB with 2 colums A, B they are composite primary key. How can I to create a query that insert in tbRelation with the result of 2 queries? wrong qu...more >>

.NET Complication (CTS)
Posted by Aditya at 11/16/2005 2:54:05 AM
class student { public string name; public student(string a) { name=a; } } what will be the output of the class in cts?...more >>

Users Count
Posted by Ravi at 11/16/2005 2:25:03 AM
Hi, i would like to know how many users are connected to the database. is there any sp. any input will be helpfull.. -- ravib...more >>

Analysis Server 2005 question
Posted by John at 11/16/2005 12:16:10 AM
Hi all, My apologies if this is off-topic in this N.G. but I'm stumped on this one! I'm playing around with Analysis Server 2005 and specifially the Business Intelligence Studio. I've managed to get a basic cube setup and am playing around in the browser tab of studio and really like th...more >>

help on SQL syntax ??
Posted by serge calderara at 11/16/2005 12:02:03 AM
Dear all, I am not so familar with SQL syntax. Is there a good link where keywords and syntax are clearly explain ? I am running SQL server 2000 Sp4 on server 2003. regards serge ...more >>

How to get last record ??
Posted by serge calderara at 11/16/2005 12:00:02 AM
Dear all, I am writing a store procedure which should return the last entry whcih has been written in a database table. That store procedure will always return the last recorded entry from a table How to do that ? regards serge...more >>

SQL 2005: Why has Microsoft taken out the "Object Search" Dialog Box?
Posted by Andreas Klemt at 11/16/2005 12:00:00 AM
Hello, why has Microsoft taken out the "Object Search" Dialog Box? Are there any alternatives? Thanks for any answer! Kind Regards Andreas ...more >>

SQL 2005: How to search stored procedures like 'Object Search in SQL 2000' ?
Posted by Andreas Klemt at 11/16/2005 12:00:00 AM
Hello, how can I search for search procedures or functions with wildcards with SQL Server 2005? Many thanks for any sugestions in advance. Best Regards Andreas Klemt ...more >>

EXISTS
Posted by Rebecca York at 11/16/2005 12:00:00 AM
Why can't I do this? DECLARE @BIT BIT SELECT @BIT = EXISTS( SELECT 1 FROM sysobjects ) I can do... IF (EXISTS(...)) SELECT .. FROM .. WHERE EXISTS(..) CASE WHEN EXISTS(...) THEN ... END So why not @BIT = EXISTS( ... ) ? ...more >>

firing a trigger on someone's birthday
Posted by Jason at 11/16/2005 12:00:00 AM
Hi, Could somebody help me create a trigger which should be executed when someone's birthday in months fall in range, like between 18 months and 36 months. If one falls in that range, the trigger should set a value for that person to 1....more >>

UNION ALL effect on ORDER BY
Posted by Stephen Howe at 11/16/2005 12:00:00 AM
Hi Running SQL Server 2000 If I do a SELECT with a 2 table INNER JOIN with an ORDER BY clause on the PK of the 2nd table and look at the plan in Query Analyser, the optimiser is bright enough to spot it does not need to Sort the results, the PK already deliveries the right order and the joi...more >>

IIF PROBLEM
Posted by Savas Ates at 11/16/2005 12:00:00 AM
in my table if ProductPrices_ID >15 then I want to change this field else i want it to not change. i wrote that code but it returns an error. how can i fix it ? SELECT iif( ProductPrices_ID > 15 ; 0 ;ProductPrices_ID ) as pele FROM ProductPrices ...more >>

DELETE SQL Query Question - Joining a Table data type and a User Table.
Posted by Peri at 11/16/2005 12:00:00 AM
Dear All, Can anyone help me to run this below query ? DELETE @_TCTableTemp FROM @_TCTableTemp , Scrip WHERE @_TCTableTemp.Scrip_Code = Scrip.Scrip_Code AND Scrip.Inst_Code LIKE 'N%' AND TC_CODE = 'STT' The error that I am getting is: Server: Msg 137, Level 15, State 2, Procedure STP_FO...more >>

Can't check "Check existing data on creation" in relationship
Posted by ghostnguyen at 11/16/2005 12:00:00 AM
Hi When I added relationship to table, checked "Check existing data on creation" and clicked "Save" in Enterprise Management tool, it has no error. However, when I check tables again, the "Check existing data on creation" option was unchecked. Help me! ...more >>


DevelopmentNow Blog