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 > march 2004

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

drop table ... cascade constraints
Posted by richlm at 3/31/2004 11:56:07 PM
Is there a simple way to achieve the equivalent of "drop table ... cascade constraints" (Oracle syntax) in SQL server 2000 - either SQL syntax or through an API The only solution I can see is to first call sp_depends and process the resultset from that before dropping the table Wondering if it c...more >>

Different ownership of objects for same user
Posted by kumar ss at 3/31/2004 11:00:00 PM
Dear Friends, SQL Server 2000. I have observed an behaviour in my sql server 2000. I have an user 'UA' assigned as the 'db_owner' of the database DB_test. I logged into enterprise manager as user 'UA' and created a table via Enterprise Manager. I saw the owner(at enterprise manager)- dbo. ...more >>

Optimizing Joins
Posted by Harman Dhillon at 3/31/2004 10:25:50 PM
I have two tables each containing records to the tune of 30,000 records... I need to create an optimized join on the two tables...Apart from creating necessary indexes is their a way to improve the join performance... The query is: SELECT DISTINCT Related.* FROM /* Ignoring duplicate rela...more >>

String to datetime
Posted by Jac at 3/31/2004 9:21:09 PM
Hi I have a string (varchar(12)) with a date in in following formats DMMYYY or DDMMYYYY I want to convert this to a real datetime First of all I am stuck with the leading zero I am missing in my string and also the european format of the string If I put the string in a smalldattime field i r...more >>

Migrating Data
Posted by Lontae Jones at 3/31/2004 9:16:10 PM
Hello I have a new SQL Server called Accouting and I would like to migrate all of the databases and sp's and security from Accounting1 SQL Server to Accounting. What would be the best way to perform this task. Any Help would be greatly apprectiated. Accounting1 is a SQL 7.0 and Accounting is ...more >>

Temp table joins
Posted by Harman Dhillon at 3/31/2004 8:06:16 PM
SELECT DISTINCT Related.* FROM /* Ignoring duplicate related records */ (SELECT b.RecordId,0 AS RecordSource,a.PayeeVendorNumber , a.GeneralizedInvoiceNumber, 1 AS Type,b.InvoiceAmountPaid FROM #TempTableForExceptionSet a INNER JOIN #TempBaseSet b ON a.PayeeVendorNumber = b.PayeeVe...more >>

auto-generate column aliases with prefix = table name
Posted by John A Grandy at 3/31/2004 7:49:48 PM
for this kind of sql : select T1.*,T2.* from Table1 T1 left outer join Table2 T2 on T1.ForeignKey = T2.PrimaryKey where T1.ForeignKey = 'nnnn' is there syntax available to cause column aliases to be used in the resultset where the aliases are constructed as TableName_ColumnName .... o...more >>

Debugging "Stored procedure in T-SQL Debugger"
Posted by Majstor at 3/31/2004 7:03:06 PM
For 2 days already Stored procedures on SQL Server don`t work. When debugging: "ODBC: Msg 0, Level 16, State 1 [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot load the DLL mssdi98.dll, or one of the DLLs it references. Reason: 126(The specified module could not be found.)." Other obj...more >>



Q: Select Statement: Join vs Inner Select
Posted by Jason at 3/31/2004 6:30:40 PM
Says I have 2 tables: tbTran & tbUser. Says the table has these fields: tbTran (SeqNo, UserID, AuthUserID, ...) tbUser(UserID, UserName, ...) Now, i need to list our the details of the transactions including the username. I have 2 options here: 1. Using Join table: "Select tbTran.SeqNo, tbTr...more >>

Calculate the total time in minute between 2 dates
Posted by JANE at 3/31/2004 5:58:27 PM
Dear All: I would like to know, how to get the total time in minute between 2 date. For example: from 30/03/2004 12:00 to 31/03/2004 20:00 Please advise Thanks ...more >>

Get Data Recursively
Posted by AD at 3/31/2004 5:02:10 PM
For the benefit of whoever is in need of this type of data retrieval. I have a table whose structure is something like this: TableName: Recursion RootID ParentID TheData ------ -------- ------- 1 1 Level 0 - Group 1 2 1 Level 1 ...more >>

StoredProc returning rows twice
Posted by CJM at 3/31/2004 4:52:36 PM
I have a SP which appears to be returning each row twice: Create Procedure Orders_ListAdviceLines @AdviceNoteID int, @LocationID int As Select s.StockMoveID, s.LineID, s.SerialNo, d.PartNo, p.CleanDesc, o.OrderID, o.CustOrderNo from StockMovements s inner join OrderDetail d ...more >>

Sp_executesql and temp table
Posted by Harman Dhillon at 3/31/2004 4:45:54 PM
Hi, I have the following code written in my sp. SET @DynamicQuery = 'SELECT @CommaListValues = ' + @fieldNames + ' FROM #TempBaseSet WITH (NOLOCK) where RecordId=' + CONVERT(NVARCHAR,@RecordId) { EXEC Sp_ExecuteSql @DynamicQuery , N'@CommaListValues NVARCHAR(200) OUTPUT',@CommaLi...more >>

accounts
Posted by Andrew at 3/31/2004 4:43:27 PM
Hello, I delete by mistake the account BUILTIN\Administrators How I put it back? Thanks, Andrew ...more >>

Behaviour of Outer Joins
Posted by Barath at 3/31/2004 4:41:10 PM
i have 2 tables test_oj(fld1 varchar(10) ,test_oj2(fld1 varchar(10) with test_oj value Fld1 ---------- test test test test test -------------------------------------------------------------- test_oj2 value Fld1 ---------- test1 test test test test test (6 row(s) affect...more >>

BUILTIN\Administrators
Posted by Andrew at 3/31/2004 4:37:04 PM
Hello, I delete by mistake the account BUILTIN\Administrators How I put it back? Thanks, Andrew ...more >>

Need help with SELECT statements.
Posted by Lam Nguyen at 3/31/2004 3:58:47 PM
Please help me with the select statements. Here is the result want show below. Thank you very much in advance. DROP TABLE #HomeProspect, #HomeQuoteProspect go CREATE TABLE #HomeProspect ( Person_id INT NULL ) GO CREATE TABLE #HomeQuoteProspect ( Person_id INT NULL, Quote_...more >>

Help: Unique over multiple columns
Posted by Matthew Speed at 3/31/2004 3:32:13 PM
I need to set up a routine to export some data to a linked server. The source table has among its many columns a three field key. I need to copy the records from this source table to a destination table. How do I run a select statement that will compare the three column key in the source table...more >>

UDF with cursor input parameter ..
Posted by Louis at 3/31/2004 3:29:54 PM
Why is this allowed: create function dbo.fnCurs(@curs cursor) returns @result table ( data varchar(50) ) as begin declare @acctNo varchar(10), @acctName varchar(100) open @curs fetch next from @curs into @acctNo, @acctName while @@fetch_status = 0 begin insert @result s...more >>

Trigger does not fire in all conditions
Posted by mayur_hirpara NO[at]SPAM hotmail.com at 3/31/2004 3:25:18 PM
Hi... I have a INSERT and a DELETE trigger defined on a table. So that when a row is inserted/deleted from it the appropriate trigger will either copy the inserted row in my personal table or delete the corresponding row from the personal table. However whenever I insert or delete rows to/from ...more >>

temporary procedures
Posted by joe at 3/31/2004 3:11:46 PM
Have anyone used temporary procedures before? what is the advantage of this? ...more >>

How can i select statement
Posted by mis at 3/31/2004 2:59:55 PM
Dear , all How can i select between SQL SERVER AND Mysql ? Thankyou ...more >>

Find the first available integer.
Posted by Star at 3/31/2004 2:36:42 PM
Hi, Let's suppose I have this: Field1 ------ 4 7 6 7 8 I want to get the first available integer. I have found many solutions on the newsgroups about this. This one, for example: SELECT LowestInt = ISNULL (MIN (MyColumn + 1), 1) FROM MyTable WHERE MyColumn + 1 NOT IN (...more >>

Dynamic GROUP BY
Posted by dw at 3/31/2004 2:34:25 PM
Hello all. We have a stored procedure where, based on a parameter, we want to include the GROUP BY clause or not include it in the SELECT. Is this possible? Thanks :-) ...more >>

Update Sequence Values Without Cursor
Posted by Jeff S at 3/31/2004 2:30:21 PM
Wondering if/how this can be done *without* using a cursor: I have a table with columns named [sequence] and [name] (sequence holds in, and name holds varchar(50)) I want to update [sequence] so that [sequence] contains integers that increment by 1, starting with 1, for all rows in the tabl...more >>

Moving SQL to a new server.
Posted by Tom Furness at 3/31/2004 1:40:45 PM
Hi, I was reading another thread about copying SQL server databases and logins to a new server. I too am going to have to move a sql instalation to a new server. My question(s) is What about Jobs, DTS packages, Linked Servers, etc? Is this not a common thing that people do? Move everything to...more >>

Simple problem that's not so simple
Posted by jhoge123 NO[at]SPAM yahoo.com at 3/31/2004 1:35:56 PM
I've got a web application where I want to show product sales by month, and want to create a stored procedure to display this. Pretty simple. The only catch is that I want to display this in a table, so I need to have a zero in the recordset for months that have no sales. What I'm doing now is...more >>

NNTP Server Name
Posted by JI at 3/31/2004 1:21:12 PM
What is the SQL Server or Microsoft Newsgroup server name?...more >>

how to declare a field/column to pass to sp as argument?
Posted by billy at 3/31/2004 1:12:59 PM
I have to get a count of rows on a table for a condition on various fields - like If something Select count(*) from tbl1 Where fld1 = 'Yes' If something Select count(*) from tbl1 Where fld2 = 'Yes' .... CREATE PROCEDURE sp1 --@fld nvarchar(50) @fld object --pseudocode As If ...more >>

How to update a ORACLE table?
Posted by Patrick at 3/31/2004 1:12:49 PM
Hi Freinds, SQL 2000 I need to update an ORACLE database table with PK in one of my SQL tables. I have the database as linked server too. I am using DTS to Transfer data between two servers. But can I use DTS to update destination server? Any other option I be able to update ORACEL tables? ...more >>

How to acces oracle tables ?
Posted by Patrick at 3/31/2004 1:10:51 PM
Hi Freinds, SQL 2000 I have a linked server for my ORACLE database . When I click on linked server I can see the server and tables. How can I access those table in a select statment? something like : select * from <linkedserver>.<tablename> I treid it but says cannot find table ! Tahn...more >>

MultiRow triggers and IF UPDATE
Posted by Harry Leboeuf at 3/31/2004 12:14:35 PM
Does the IF UPDATE(ColName) work in a multirow trigger ? Does it flag if one of the rows has tha ColName updates or if all rows have that column updated ?? Thx ...more >>

Auditing/Archiving Methods
Posted by JI at 3/31/2004 12:01:17 PM
I am tasked with determining the best way to archive changes. That is when a column in a row changes (i.e. Person's Last Name is changed) I have to be able to show the person as the were before and after the change and when the change occurred. I have done this three different ways in the past and w...more >>

how to use debugger for Stored procedures?
Posted by Billy at 3/31/2004 11:58:56 AM
Hi, I opened up the debugger in Query Analyzer for my SP's. I got it to work once - maybe on an sp that did not take any arguments. But I am trying to debug an sp which takes arguments. I have placed breakpoints in the debug window and run the sp from the query analyzer window with the...more >>

program to fill random content?
Posted by Guy Brom at 3/31/2004 11:45:18 AM
Is there a program to fill random content, based on rules, on mssql2k? Thanks ...more >>

Is there any method for getting definite number of records?
Posted by Ray at 3/31/2004 11:37:17 AM
Hi all, I would like to ask is there any method for getting definite number of records? For example, I have a field for date in the table and I would like to get 50 records before a date. Is there any sql statement for getting the records? Thanks a lot, Ray ...more >>

count total number of columns
Posted by Vad at 3/31/2004 11:29:56 AM
Hi, Is there a way to count number of columns for specific table from Information_Schema.Columns? Example I have table News and I need count of columns named News"number"Text NewsID NewsDescirption News1Text News2Text News3Text News4Text News5Text News6Text...more >>

EXEC alternate
Posted by Eric D. at 3/31/2004 11:29:53 AM
Hi, Is there an alternate way to run a SQL statement stored in a varchar then to use EXEC. Example: =================================================== DECLARE @SOME_STRING VARCHAR(500) DELCARE @USERID INT SET @USERID = 1 SET @SOMESTRING = 'SELECT * FROM SECURITY WHERE USERID = ' + ...more >>

formatdatetime inserts 1/1/1900 instead of current date
Posted by rapp25 NO[at]SPAM hotmail.com at 3/31/2004 11:28:54 AM
Hi: I am starting to rip my hair out. I pretty much tried everything. I want to insert following values: sqlString = "INSERT into myTable (ProductID, Name, Title, CategoryID, Organization, Address, City, State, Zip, Country, Phone, Fax, Email, Heard, Referral, Computer, Implement, Descr...more >>

Is it possible to find the computer name of a logged user?
Posted by ThunderMusic at 3/31/2004 11:09:52 AM
Hi, I'm writing a trigger that will modify some fields in a record to reflect some facts like the last user that modified the record and the computer on which he was. I currently use SUSER_SNAME() to find the user name, how can I find the Computer Name? Thanks ThunderMusic ...more >>

SQL Server Enterprise Manager - Stored procedure's template
Posted by Ruslan at 3/31/2004 11:09:10 AM
Hi, In the SQL Server Enterprise Manager when I create a stored procedure by default the "CREATE PROCEDURE [OWNER].[PROCEDURE NAME] AS" text exists. In which file this text is located? Thank you Ruslan ...more >>

update query problem
Posted by rocket NO[at]SPAM office at 3/31/2004 10:35:39 AM
Hi all, i have problem to update a table with following query, which fail = both in query analyzer or by VB app. have error "[Microsoft][ODBC SQL = Server Driver]Syntax error or access violation" the query : UPDATE Email SET EmailDT=3D'31 Mar 2004' WHERE = Idx=3D{BDF51DBD-9E4F-4990-A751-5...more >>

Pass a Proc a Dynamic AND to the Where clause?
Posted by JDP NO[at]SPAM Work at 3/31/2004 10:23:58 AM
I want to be able to pass an optional dynamic and to the where clause. I want the entire assembled query to be parsed and if it fails to parse I'll return a user defined parse error code to the calling application. Basically in the proc, I want to be able to parse the assembled query prior to...more >>

Enforcing Uniqueness
Posted by ChrisB at 3/31/2004 10:11:01 AM
Hello: I am involved in the the creation of a .NET application that makes use SQL Server 2000 and was hoping for some insight into the following question. Our database has a Customer table with a MedicareNumber field. It is a business requirement that the Medicare field be unique for all ac...more >>

restore database - with move
Posted by JT at 3/31/2004 10:06:03 AM
i'm trying to create a backup of databaseA and then restore this database to databaseB. however, i do not want to overwrite the databaseA files. i'm thinking i need to use the 'With Move' command, but im not sure how to do this. i want databaseB to exist on the same drive as databaseA, but i...more >>

Extended SP
Posted by Ramesh at 3/31/2004 9:59:16 AM
Hii Can anyone tell me the difference between normal stored procedures and extended stored procedures? TIA Ramesh :) ...more >>

Create a index on two tables?
Posted by Klaus L Jensen at 3/31/2004 9:55:38 AM
Can I do this?? have two tables.. [table1] addressnumber (ID) referencenumber guestnumber [table2] addressnumber (ID) adresstype addresstext Now I need to create a Uniqe index on: table1.referencenumber, table1.guestnumber, table2.addresstype Can this be done???? Med v...more >>

Case statement error
Posted by Rahul Chatterjee at 3/31/2004 9:49:49 AM
Hello All I am trying to execute the following sql statement - what am I doing wrong as I am getting an incorrect syntax error Declare @typ char declare @rate decimal select GroupID, Contrnum, Secid, SN, Lastname, Firstname, MI, Fund1COntr = Case WHEN Fund1Fringe =1 SET @TYP = (S...more >>

Disable triggers for a particular DB User
Posted by Mike Kanski at 3/31/2004 9:31:24 AM
Is there a way to disable triggers only for a particular DB User or a Group of users? There is a user in our db called 'sysmgr' and he runs updates and refreshes db on monthly bases. Every table in our db has an audit log administered by a trigger, when 'sysmgr' does any modif. to the db we do...more >>

Help with sequel statements please...
Posted by Lam Nguyen at 3/31/2004 9:23:19 AM
Hi all, I have the query below and wonder if you could show me a different way to write the query and get the same result. I have thousand of rows and I am try to avoid using GROUP BY clause. Any help would greatly appreciate. Please look at the result want below. Thanks. -- Creating...more >>


DevelopmentNow Blog