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 > july 2004 > threads for thursday july 15

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

How to create multiple stored procedure by executing the command e
Posted by Rishi Kant at 7/15/2004 11:25:01 PM
I am facing a problem : i have created a stored procedure : Create Procedure CreateProc @Str Varchar(8000) As Begin exec(@Str) End Through Query analyser, i am executing stored procedure : CreateProc 'Create Procedure dbo.Stmt as Select * From Dept Go Create Procedure ...more >>


nested transactions are reference counted
Posted by Matt at 7/15/2004 11:23:01 PM
I want to know nested transactions should be reference counted? i.e. If there are 3 BEGIN TRANSACTION, then there should be 3 COMMIT TRANSACTION? thanks! ...more >>

object model to table design mapping problem
Posted by Matt at 7/15/2004 9:51:54 PM
Given the object model, I want to design the database tables. The object model is that school has a list of courses. The following are my 2 approaches. My question is which one is better? Should table COURSE has the foreign key of table SCHOOL? Or table SCHOOL has the foreign key of table COU...more >>

varchar2 datatype in MS-SQL
Posted by Matt at 7/15/2004 9:24:24 PM
I want to know if VARCHAR2 data type is not valid in MS-SQL. In SQL Query Analyzer, it is successful to parse the following query. But when I execute it, it has the error messages "Column or parameter #1: Cannot find data type varchar2." CREATE TABLE STUDENT ( NAME varchar2(50) not null,...more >>

Removing email attachments with T-SQL
Posted by rmathuln NO[at]SPAM pacbell.net at 7/15/2004 8:39:00 PM
I want to be able to monitor an Exchange mailbox for specifically formatted messages with a stored procedure, and when they arrive save an attached file to the file system. I don't think there is any way to do that with the SQL MAIL stored procedures. I've tried using the SP_OA.. procedures and...more >>

Adding results from count
Posted by Zwi2000 at 7/15/2004 8:16:15 PM
Hi, This might be an easy one for you. I have an sql which counts number of records, each statement returns one value, and I need to add the 2 values: SELECT COUNT(*) AS TOTALI94s FROM users WHERE FirmId = 1 AND archivedcont = 0 AND I94DateD BETWEEN getdate() and (getdate()+30) SELECT...more >>

2 table query - help
Posted by Timothy V at 7/15/2004 7:52:07 PM
Hi, I'm have trouble with a query i want to make. I hope someone can help. OtherUsers(userID, roleID) ClassUsers(userID, classID, roleID) Above you can see the three tables and their columns. I want to a userID to be specified and then have a column with the roles he/she is assigned to. Ob...more >>

SELECT problem
Posted by mark at 7/15/2004 7:36:42 PM
Hello All. I am using an SQL Server 2000 db and have an address table as follows:- CREATE TABLE [Address] ( [AddID] [int] IDENTITY (1, 1) NOT NULL , [Street1] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Street2] [varchar] (5...more >>



Logging in irrespective of database access
Posted by Laphan at 7/15/2004 7:21:55 PM
Hi All Wonder if you could shed some light on a really weird problem. Basically we use a standard client side app that comms with 2 x SQL 2000 db. This SQL 2000 db sits on a Win2003 Server quite happily. The client apps sit on WinXP or Mac OS 9 quite happily. In SQL Enterprise Manager...more >>

Select multiple Count depending of a condition
Posted by AA at 7/15/2004 6:21:18 PM
I need to get the count() of rows that match two condition but I need to get in diferents columns, one for each count. :S Something like this... (this is a pseudo code) Select Count(*) as Counter1, Count(*) as Counter2 from myTable WHERE Case When (Column1 = 'value1' and Column2='value2) Th...more >>

How do I create a Crosstab query
Posted by Noel Ramirez T. at 7/15/2004 5:47:57 PM
Hi, How do I create a Crosstab view like the crosstab queries in Access? I understand crosstab as a table of numeric values with labels in X-axis and Y-axis. Thanks ...more >>

Using a calculated column in a WHERE clause
Posted by Mike Eaton at 7/15/2004 5:30:02 PM
Hi there, The idea is that I need to be able to search two tables for a certain name using LIKE. I created SQL that generates an aggregate of first_name and last_name with the alias full_name, but I can't seem to be able to use it in the where clause. Here's what I've done so far: table_1 ...more >>

Performance of Nested Views
Posted by Abraham at 7/15/2004 5:17:48 PM
In Our application there is a method which contain a series ( around 7 ) of functions ( we can think it as sql queries). Earlier we use to create one table for each fuction out put and use it as the input to next function. ( we use simple recovery model) Things were working at that time , but to...more >>

restore from script- exclusive access
Posted by G. Dean Blake at 7/15/2004 5:10:01 PM
When I do the following.... -- Create a backup device for the subcontractor database USE subcontractor EXEC sp_dropdevice 'myOLDSCDB_1', DELFILE EXEC sp_addumpdevice 'disk', 'MyOLDSCDB_1', 'd:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyOLDSCDB_1.dat' -- Back up the full subcontract...more >>

Cursors
Posted by Panks at 7/15/2004 5:09:29 PM
1) Can anyone explain in simple the effect of SCROLLABLE and SENSITIVITY on the different types of cursors. 2) I am a newbie. i want to practice Procedures, cursors, triggers and joins.Can anybody tell me where can i find exercise to practice these ? Thanks Panks ...more >>

err i meant: on update, how to dynamicaly get what fields changed?
Posted by Daniel at 7/15/2004 4:47:47 PM
Is there any generic way to get the names of the columns that were changed after an update statement? Must i compare each colunn or is there some soft of sql server mechanism for getting the list of fields that changed after an update statement? ...more >>

how to get what fields changed after insert statement
Posted by Daniel at 7/15/2004 4:46:55 PM
Is there any generic way to get the names of the columns that were changed after an update statement? Must i compare each colunn or is there some soft of sql server mechanism for getting the list of fields that changed after an update statement? ...more >>

Can i reuse the code in triggers??
Posted by Welman Jordan at 7/15/2004 4:34:45 PM
Hello all, I have several tables, each of them has a Delete trigger like the following: ---------------------------------------- Create TRIGGER tr_t1_Delete ON dbo.Table1 After Delete AS Set NoCount on Delete rr from ResourceRating rr inner join deleted on rr.GUID = deleted.GUID D...more >>

Change field collation
Posted by Jeroen at 7/15/2004 4:29:37 PM
Hi, is there a way to change the collation of *all* char/varchar fields in every table in a given database? I can do it like 'alter table XYZ alter column Afield char(50) collate Latin1_General_CI_AS' for every field but that's a hell of a job... Groeten, Jeroen...more >>

retrieving login information
Posted by anonymous NO[at]SPAM discussions.microsoft.com at 7/15/2004 4:26:14 PM
hi. I am trying to create a trigger on update and in the process i want to capture the machine login information (which may be different from the credentials used to login to SQL). I looked at using "select suser_sname()" but this returns the SQL login info. Please assist. Thanks....more >>

sql join problem
Posted by NoSf3RaTu at 7/15/2004 4:25:57 PM
Hello, I have two tables to join here is a simplified view of them Master table rec_id, company, name... 1, xyz, jack 2, yxy, sam detail table rec_id, contacted_on, contacted_by,line_id 1,'01/01/04',kevin,1 1,'05/01/04'kevin,2 2,'01/01/04',joe,1 ...more >>

How Selecting based on 1 duplicate column and one not-duplicate co
Posted by Alpha at 7/15/2004 4:08:02 PM
Now that I got the duplicate rows(using the codes below), I need to select rows that have same value in cloumn 'inovice_number' but different 'trip_ticket'. How can I do that? SELECT tblInvoice.invoice_number, print_date, tdate, trip_ticket FROM tblInvoice JOIN (SELECT tblInvoice...more >>

Using Convert(varbinary, SomeFloat)
Posted by Jack at 7/15/2004 3:57:05 PM
I have a table which includes some floating point information. I need extract it to a file that stores the values in binary format. If the floaing point value is 33 and you: run: convert(varbinary, val)) - you get - 0x4040800000000000 or run: convert(varchar, convert(varbinary, val)) - you...more >>

Can't drop a column from a table
Posted by TOM (AB) at 7/15/2004 3:40:03 PM
Anyone know a way to drop a column from a table with a non-default constraint? ex. ALTER TABLE TEST ADD TEST_DATA1 smallint NOT NULL DEFAULT 0 GO ALTER TABLE TEST DROP COLUMN TEST_DATA1 GO Fails because a constraint on the column. The column can be dropped via SQL Server manager GUI, but I ...more >>

T-SQL In Domestic and International DBs
Posted by Proc at 7/15/2004 3:17:43 PM
I need some advice, so here is a case scenario for anyone that has some: I have two separate databases that are identical with the exception that some fields in the first database are varchar and those same fields in the second database are nvarchar. Each database has a TON of data in them. I...more >>

DTS export moving tables not selected
Posted by yaktipper NO[at]SPAM yahoo.com at 7/15/2004 3:02:39 PM
Running the DTS export wizard in SQL Server Enterprise Manager in SQL Server 2000 (build 2600.xpclient.010817-1148), I selected copy objects, and chose 21 sprocs and 5 tables to move. I selected extended properties. The transfer dropped and created the 5 tables I had selected, and 3 tables t...more >>

is there a fix for cxpacket wait type?
Posted by ===steve pdx=== at 7/15/2004 2:56:40 PM
background: sql2k (with sp2) on nt5 I have encountered the "cxpacket wait type" when running queries that used parallel processing. and my reports based on those queries are very slow. Looking at the various articles on the web, there does not appear to be a definiative answer on how to correc...more >>

Parent child
Posted by DaveF at 7/15/2004 2:55:02 PM
I am trying this sql: select distinct gbl_no from track.v_latestpntdtts order by gbl_no I also want to get sereral other fields in those rows to, like... select distinct gbl_no,TCN,TRAC_NO,CAT,SRC,HAZ from track.v_latestpntdtts order by gbl_no I only want gbl_no to be distinct Dave ...more >>

I need get the last 12 Month do my table. (DATE TIME QUESTION)
Posted by RTF at 7/15/2004 2:44:35 PM
Hi, I need get the last 12 Month do my table. How i do this. I try: SELECT GETDATE() - MONTH(12) But this command decrement the Days and not Months complete sql: SELECT * FROM tblPrivateLabelVenda WHERE PrivateLabelVendaPrivateLabelNumero = 1001706752717617 AND PrivateLabelVendaDataDaVen...more >>

how to execute a stored procedure from another stored procedure (nested)
Posted by AA at 7/15/2004 2:30:12 PM
I have one SP with two variables @Var1 int @Var2 int When I execute the nested SP from other SP, passing output parameter.. like this Execute myOtherSp @Var1, @Var2 <-- Both param are marked with the "out" property The @Var1 and @Var2 never come back with value, the result for both is...more >>

transaction in Linked Server
Posted by cctwong at 7/15/2004 2:12:53 PM
Hello All, I have 2 SQL 2000 servers linked , but when I run the following stored procedure, it will wait forever without any error messages. However, when I take ou the begin tran, it works fine. begin distributed tran INSERT INTO [LinkedServer].dbName.dbo.table(field001) VALUES ...more >>

Stored proc and null value
Posted by Michael Culley at 7/15/2004 1:49:59 PM
If I have something like below this in a stored proc, does it work if @Value is null? A simple test shows that it does but in a more complicated stored proc it doesn't. @ID always comes out null and so it is inserting duplicates. Does it only work in some situations? Thanks Michael Culley ...more >>

problem with migrating DTS package from file to server
Posted by Andrew Baker at 7/15/2004 1:34:34 PM
Sorry about the cross post, but I need an answer by the end of the week. I am trying to migrate a DTS from a file into the server. I dont know what user name or password will be on the target PC, so I cant specify them, but the integrated security gives the user ability to connect. On my dev...more >>

Stumper?
Posted by MB at 7/15/2004 1:18:01 PM
I have a single table. Key Group Date ---- ------- ------ 1 1 1/1/2004 2 2 1/1/1999 <---- eliminate 3 2 1/7/2004 4 3 1/3/2004 <---- eliminate 5 3 ...more >>

IS THIS A DATE OR CHAR?
Posted by alax at 7/15/2004 12:59:04 PM
HELLO, HERE IS AN EXAMPLE. CONVERT (CHAR(8), DATE, 10) NOW IS THE RESULT OF THAT A CHAR OR DATE? IF SO CAN I COPNVERT THAT FORMAT BACK TO A DATE? THANKS. ...more >>

tempdb is skipped. You cannot run a query that requires tempdb
Posted by Mike Hagen at 7/15/2004 12:36:01 PM
Has anyone seen the SQL Server error: "tempdb is skipped. You cannot run a query that requires tempdb"? We're running a .Net web application with a SQL Server 2000 backend, and we get the error intermittently. Restarting the SQL Server service seems to fix it, as it causes tempdb to b...more >>

Getting "SQL Server does not exist or access denied" error messages
Posted by Rod at 7/15/2004 12:19:54 PM
For some reason, this week we started to get "SQL Server does not exist or access denied" error messages when attempting to connect to our SQL Server databases. This only affects people who dial into our network. But this seems to be a rather complicated situation, so let me explain. We have a...more >>

id counter
Posted by alax at 7/15/2004 11:54:42 AM
hello, is thier an easy way to creat a temp column in a select statement that will number the rows? ...more >>

nvarchar vs. varchar
Posted by ===steve pdx=== at 7/15/2004 11:34:23 AM
background: sql2k on nt5 can any one tell me if nvarchar(4000) the same as varchar(8000)? thank you. ...more >>

Select & Order By UserID
Posted by Greg at 7/15/2004 11:12:20 AM
Is there a way to return fields in the same order they been passed to where clause by UserID? Example SELECT User.* FROM User WHERE UserID IN (2002,1001,958,2453,3454) Any Ideas? Thanks a lot, Greg ...more >>

What's the best practice for primary keys?
Posted by Jay Douglas at 7/15/2004 11:10:57 AM
Another theoretical SQL development question: Our development team has had several heated discussions over what a primary key should be in SQL tables. Some say that every table should have an auto increment int ID field for the primary key allowing for ease of use in development and ...more >>

indexing views?
Posted by dimitris at 7/15/2004 11:08:01 AM
Hi, This is a catch 22: Iam trying to create index in views. I take ownerhip of the dependencies, and run: CREATE UNIQUE CLUSTERED INDEX IV1 ON dbo.BMRUNSTEPSPREADING (RECID, DATAAREAID) GO Then I get the error: Server: Msg 1939, Level 16, State 1, Line 1 Cannot create index on view ...more >>

Backup/Restore from Program
Posted by G. Dean Blake at 7/15/2004 10:59:58 AM
How can I backup and restore a SQLServer DB from a .net VB program? Thanks, G ...more >>

CREATE DATABASE permission denied in database 'master'. Could not attach database
Posted by Al sqlserver at 7/15/2004 10:55:53 AM
CREATE DATABASE permission denied in database 'master'. Could not attach database 'IBS_DBSAuditMergeComplete' to file 'C:\Documents and Settings\ALT\My Documents\My Stuff\fNew Format\IBSConsolidated\IBS_DBSAuditMergeComplete.mdf'. I'm trying to connect to a sql server database using sqlDataAda...more >>

Time Zone question
Posted by Rob T at 7/15/2004 10:52:04 AM
This is just a general question....trying to collect some ideas on how to approach this issue: I have a web app that has users across the country. Since they login, I can make their profiles have a time zone field, so that's no big deal. My data in question is stored in SQL 2000 in a dateti...more >>

Summing last 6 months...
Posted by Zach Wells at 7/15/2004 10:47:50 AM
Below you'll find the DDL for this problem. I'm trying to create the fact table that will go into a cube. The basic question I'm trying to answer is "for each sales_id, how many unique clients had activity in the last 6 months", activity being defined as a client having a joborder created. ...more >>

Date Formatting
Posted by Paul King at 7/15/2004 10:37:04 AM
Any help would be appreciated. I have an ASPX code that outputs a ListBox containing our venue dates. However some of the entries in our Database are missing and therefore in the results this shows up as blank. Here is the code... Dim strSQLforListBox As String = "SELECT VenueDate, VenueI...more >>

Stored Procs based on Views
Posted by mkerrigan NO[at]SPAM ktoys.com at 7/15/2004 10:28:49 AM
I have inherited a database with several dozen stored procedures that are simply: SELECT * FROM (view name) Is this a good idea? Wouldn't it be better just to put the view's SQL directly into the stored procedure? I don't believe these views are being used other than by the stored procs t...more >>

Database Structure Debate
Posted by Scott Rymer at 7/15/2004 10:27:45 AM
We are currently looking at ERP software solutions for our business and I am getting rather mixed messages from multiple vendors regarding what defines efficient use of SQLServer (or any other RDBMS) given todays technologies. On one side, we have companies offering multiple RDBMS deployments (Or...more >>

Intellectual Property Considerations
Posted by Major Johnson at 7/15/2004 10:02:54 AM
Just wondering what the options are for protecting, hiding, or somehow obfuscating source code of stored procedures in a hosted environment. Thanks. ...more >>

Long Sproc Names
Posted by Chris at 7/15/2004 10:00:03 AM
Are there any ramifications to creating extremely long stored procedure names? Like 70+ characters long... Thanks in advance, Chris...more >>

Getting results of DBCC or SP into a cursor
Posted by Carl Unternahrer at 7/15/2004 9:44:45 AM
I'm sure this has been asked but my searchs haven't given me any fruit for my labor so here I am. Two exmaples below is what I want help on. I know they don't work which is why I'm here but they get the point across of what I'm trying to do. --I'd like this in a cursor Declare cCursor Cursor...more >>

ALTER DATABASE
Posted by Gerard at 7/15/2004 9:41:06 AM
Can someone tell me what is wrong with this statement: USE master GO ALTER DATABASE gms SET SINGLE_USER It passes syntax check, but when I run it, it just sits there and does nothing. I let it run for 4 min before stopping the query. Any help is appreciated as always. Thanks, Gera...more >>

SQL Comparison of ISNULL values
Posted by dan_williams NO[at]SPAM newcross-nursing.com at 7/15/2004 9:14:00 AM
I'm attempting the following SQL query:- SELECT table1.id from table1 left outer join table2 on table1.id = table2.id where ISNULL(table1.number,0) <> ISNULL(table2.number,0) But the damn thing won't work when either of the tables contain NULL values. How do i go about comparing two va...more >>

pre-process eval of @localvar in osql :r stmt
Posted by Martin at 7/15/2004 9:12:05 AM
Hi, I want the equivelent of a pre-processor #define in my osql script. I want to include a script with :r, but I've got the directory defined in a @localvar. This doesn't work because the localvar is not evaluated before the :r (understandably). How to get round this? Thanks Martin ...more >>

USE @localvar?
Posted by Martin at 7/15/2004 9:09:14 AM
Doesn't seem to work. (get syntax error) How can I get round this? I'm using osql to string a load of sql scripts together that can each run on different dbs. Thanks Martin ...more >>

Changing a filename or removing a file
Posted by Richard at 7/15/2004 9:08:11 AM
I had to add a log file to a online database in an emergency last week. Now I want to either chane the logical file name (i.e. Test to test.ldf) I forgot the ldf extension, without restarting sql server. Or I need to remove the file. I reied to empty the file first, then remove it, but I h...more >>

Query working finse on Sql Server 6.5 and not working on Sql Server 2000
Posted by picknick75 NO[at]SPAM hotmail.com at 7/15/2004 9:01:39 AM
HI all, I have a problem with the following query. It works fine on Sql Server 6.5 but in Sql Server 2000 it doesn't work good, it give me out more rows than using 6.5 (that gives the right result). I think the problem is related to the use of left outer join and some setting related to ...more >>

Using KILL to kill several PIDs in a Loop cycle.
Posted by Elias at 7/15/2004 8:24:04 AM
Hello, I'd like to know if it's possible to issue a kill command passing a varible instead a simple value. I tried the folling with no success: DECLARE @ID INT SELECT @ID=3D58 KILL @ID =BFAny idea on How to accomplish this? Thanks in advance. ...more >>

How to know the DB name?
Posted by simone.79 NO[at]SPAM tiscali.it at 7/15/2004 7:53:41 AM
I'm working on SQL Server 2000 and I would to know the open DB name into a stored procedure. Any suggestion? Fluido...more >>

Understanding dbo, etc.
Posted by Jay at 7/15/2004 7:15:28 AM
I have a situation where views and sps cannot compile on an external sql = server. The error message is unrecognized object: FullName. FullName = is user defined function that compiled just fine. In the views and sps I use FullName by using "dbo.FullName". This has = always worked. I di...more >>

How to Limit to TOP 10 LIST for each entry of column
Posted by wiredog NO[at]SPAM comcast.net at 7/15/2004 6:50:07 AM
I have been reading the newsgroups about ranking queries and trying to read SQL Queries for Mear Mortals to get the basic structure right. Its easy for me to list STATION_NAME and then the SONG_NAME by TIMES_PLAYED DESC, but ONLY the TOP 10 for EACH Station is a twist for me. This is how a p...more >>

Aggregating store procedure
Posted by Przemo at 7/15/2004 6:03:04 AM
Hi, I have such a data Name, Value 1, Value 2 John, 2, 7 Ana, 4, 5 Luke, 1, 20 I would like to receive a report based on Value2-Value1 showing how many records is beetwee 0 and 3, 4 and 6, and more then 7, for eg. col1, col2 'between 0 and 3', 1 'between 4 and 6, 1 'more than 7, 1 ...more >>

Updating subset of data
Posted by Tom Shin at 7/15/2004 5:30:41 AM
Here's the problem. I've got a large database of records (93 million). In trying to update a column, the transaction log filled up the remaining space on the hard drive before completing, thus the query didn't update. According to this knowledge base article: http://support.microsoft.com...more >>

Communicating progress of stored procedure to ADO client
Posted by Nikki Locke at 7/15/2004 4:15:02 AM
I have some very long running (20 mins) SQL server stored procedures. I would very much like to give the client (a VB program) some idea of how the procedure is getting on - ideally a progress bar. I can easily calculate the percentage complete in the stored procedure, but how do I communicate...more >>

Drop down lists
Posted by Paul in Harrow at 7/15/2004 3:34:04 AM
Hi there, I have two tables - "tblTutors" which holds contact details and includes the field "TutorName" (the Primary key) the other table is "tblClasses" which which also has a field called "TutorName". Is it possible for all the names from tblTutors to apear as a drop down list on tblClasses or ...more >>

Finding duplicate data
Posted by Peter Rooney at 7/15/2004 3:23:10 AM
Hi, I am trying to build a stored procedure that will display data that meets certain conditions, the procedure as it stands below produces the correct results in that it only displays records where the RENTAL and CIL_BIL_FLAG fields are equal to Y, but what I want to do is then dig further a...more >>

Date Comparison in SQL
Posted by a.nasir NO[at]SPAM ieee.org at 7/15/2004 1:50:00 AM
I have a very basic level question. I want to make comparison over date portion. Select * from MyTable where MyTable.Datefield='2003-09-21' does not return me correct result because data in MyTable.Datefield has time infomation as well. I have come up with the following SQL Select * from M...more >>

Trigger Update - Help?
Posted by Konstantinos Michas at 7/15/2004 12:46:11 AM
Hello Experts, I come up with my issue again: I want to update one or more columns of a table using the values of "trigger table" and when values are different. I don't think that this is the right way write the statement because when I update only one column of the four, then the "sta...more >>

suppressing parameters based on conditions?
Posted by Moe Sizlak at 7/15/2004 12:21:41 AM
I have a procedure below that I am using to update / insert based on the @directive parameter passed in, some of the parameters I wish to suppress from the update but when I try to of course the stored procedure tells me that it's expecting that parameter. How can I suppress some of the paramete...more >>


DevelopmentNow Blog