all groups > sql server programming > march 2005 > threads for thursday march 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
@@error can only capture limited error number?
Posted by LBT at 3/17/2005 11:11:04 PM
Hi experts,
I'm quite confused with the using of @@error in Microsoft SQL 2000. For
instance,
Select * From Table1
If @@error <> 0
print 'Got error!!!'
I can have the @@error to capture the error number 208 (Invalid object name
'Table1') if the specific table is not found inside data... more >>
Performance question for begginers
Posted by gwenda at 3/17/2005 11:05:03 PM
Hi,
On an SQL 2000, which of the following queries will have better performance:
select * from Phones
where ContactID in (select ID From Contacts where ClientID = 14)
Or
select * from Phones
inner join Contacts on Phones.ContactID = Contacts.ID
inner join Clients on Contacts.ClientID ... more >>
sum of coloumns from two tables
Posted by vijay at 3/17/2005 9:25:01 PM
Hi,
How can I add the VISIT Coloumn in the following tables, any pointers,
help is highly appreciated.
Tbl 1 Tbl 2
memno visits memno visits
A1 1 A1 1
A2 1 A2 ... more >>
Creating an aggregate function
Posted by MuZZy at 3/17/2005 9:12:24 PM
Hi,
Is there a way to create an aggeregate function in MS SQL?
For example, if you wanted to re-implement fucntion SUM(), how would you do that?
Any ideas would be highly appreciated!
Thank you,
Andrey... more >>
excluding records that are already present in a table...
Posted by Nestor at 3/17/2005 9:09:24 PM
Hello, I'm stucked with trying to identify records that are already present
in a table when queried from another table....
For example, if I have 2 tables (Table A and Table B), Table B has 3 fields
(a,b,c) out of which (a,b) are primary keys. I'm trying to insert records
into Table B from Tab... more >>
PLS HELP:Merge cells - use cursor?
Posted by MuZZy at 3/17/2005 8:26:26 PM
Hi,
I just wonder if someone could help me here:
Say, i have a table with one column: 'Name'
Name1
Name2
Name3
....
I need to get the string of "Name1, Name2, Name3, ..."
The only way i see is to use cursor - but i know cursors aren't the best way if an alternative exists...
So is... more >>
IIF,ISNULL in transact sql
Posted by Sql Fren at 3/17/2005 7:49:04 PM
I have this query in ACCESS VBA:
SELECT DISTINCT qryRCP.RCP_VendorID, Sum(IIf(nz([RCP_ReceiptQty],0)=0,0,1))
AS fldNbrRcpts,
Sum(IIf(nz([SumOfRCQ_RejectQty]+[SumOfRCQ_ScrapQty],0)=0,0,1)) AS
fldNbrRejScrap
FROM qryRCP
WHERE qryRCP.RCP_ReceiptQty >=0
GROUP BY qryRCP.RCP_VendorID, qryRC... more >>
Excessive Latch Wait
Posted by Lonnye Blake Bower at 3/17/2005 5:48:14 PM
Good evening,
Does anyone have advice on how to trim down excessive latch wait time?
One particular query (stored procedure) is to blame for almost all of it.
This query is joining 7 tables... 1 of which is joined twice... another of
which has several million rows in it.
The query has nolocks t... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Add a default value to an existing column
Posted by krygim at 3/17/2005 5:38:13 PM
How can I add a default value to an existing column via T-SQL? I tried the
following but not successful:
Alter Table MyTbl Alter Column MyCol Int Default 0.8
TIA
... more >>
script to shows all dbs on all servers.
Posted by ishaan99 via SQLMonster.com at 3/17/2005 4:36:56 PM
I am writing a script that would give me databases of all servers. I also
need to know whats the database size fo each database on each server. The
way i get teh first one working was set up linked server to all databases
that i need the information from. Then for each server get the databases
f... more >>
'Cannot start transaction while in firehose mode'
Posted by Alien2_51 at 3/17/2005 4:35:02 PM
I'm getting this error message in one of my procedures... Has anyone ever
seen this, I've searched the group's most messages I found mention a firehose
cursor which I know I'm not using... Here's the procedure thats generating
the error, this is the first time I've seen this error the applicat... more >>
debugging sp sql 2000
Posted by stefano ceccato at 3/17/2005 4:10:40 PM
Hi All.
I'm running SQL Server 2000 sp3 over a Windows 2003 Server, and my client
machine is a XP Pro sp2, with SQL Clients sp3.
I cannot debug stored procedure from my client machine and i recieve this
error:
Server: Msg 504, Level 16, State 1, Procedure sp_sdidebug, Line 1
[Microsoft][... more >>
Parsing result in SPROC
Posted by Mitch MRC at 3/17/2005 4:08:37 PM
Hello all.
I have this code:
DECLARE @a varchar(500)
SELECT @a = (SELECT DISTINCT ProgrammName FROM Programmes)
I got an error because the query returns more than one row. But the main
problem is that I want with the result from that SQL to do some operations.
How can i get the individua... more >>
group by
Posted by John Grandy at 3/17/2005 4:01:51 PM
GROUP BY Clause
Specifies the groups into which output rows are to be placed and, if
aggregate functions are included in the SELECT clause <select list>,
calculates a summary value for each group. When GROUP BY is specified,
either each column in any non-aggregate expression in the select lis... more >>
why two dot here?
Posted by fridaydream at 3/17/2005 3:51:20 PM
say
SELECT error, severity, description
FROM master..sysmessages
~~~why two dots here?
but replace it by "master.sysmessages"
will generate an error
ORDER BY error
Thanks in advance:)
... more >>
in tsql, given the table or view myfoo(date1, date2) how do i list out the differences number of miliseconds, seconds and minutes, hours and days betw
Posted by Daniel at 3/17/2005 3:38:49 PM
in tsql, given the table or view myfoo(date1, date2) how do i list out the
differences number of miliseconds, seconds and minutes, hours and days
between date1 and date2 for each row?
... more >>
working with xp_sendmail
Posted by telenet at 3/17/2005 3:04:40 PM
I'm working with sqlserver2000 on a server2003.
My e-mail via xp_sendmail is working good.
But I have one problem --> every mail I send via xp_sendmail does not appear
in de sent-items van the account of the mapi on my server.
Can someone give a hint to solve this problem ?
thanks
Gee... more >>
SQL Query
Posted by Terry Matthews at 3/17/2005 2:38:04 PM
Hi,
I'm not sure what the correct newsgroup is to post this to, if this is not
right please let me know.
I'm very new to writing SQL queries and I have a couple questions.
My situation:
I have a table that has a ton of applications in it listed by name,
manufacturer, version, and the P... more >>
struct : why needed ?
Posted by John Grandy at 3/17/2005 2:28:54 PM
Could someone elaborate on typical scenarios in which a struct is valuable
or necessary in a db-design ?
... more >>
Not Returning Records From a TempTable sp that works on ISQL
Posted by Steve House at 3/17/2005 2:23:19 PM
I work for an insurance agency that needs to run a multitude of checks on
applications when they are added to our database. A large union query in a
stored procedure works just fine, but is slow. I want to create a temp
table, transfer the data into it, then run the union query against it. Thi... more >>
NULL values in XML string
Posted by Andre at 3/17/2005 2:20:08 PM
Can someone tell me how to format my XML string so when I load it into my
table the field actually has a NULL value and not an empty space?
My XML string is formated like this.
<reimbursement>
<tbl_Reimbursement>
<Type10Rec Provider_Type='INSTIT' Provider_SubType='11' ReimDesc=""
Status='P... more >>
smalldatetime output to 'mmddyy' format
Posted by Joe K. at 3/17/2005 2:20:07 PM
What is the simpliest way to output from a SQL statement using a table that
has a field with the smalldatetime format to output to 'mmddyy' format.
Please help me with this issue.
Thanks,... more >>
SERIALIZABLE isolation level
Posted by sxiang NO[at]SPAM student.math.uwaterloo.ca at 3/17/2005 2:01:04 PM
Greetings All:
If I have the following code snippet (in a stored procedure):
-----------
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANS
SET @key = MAX(id) FROM app
SET @newkey = @key + 1
INSERT INTO app(id) VALUES (@newkey)
COMMIT TRANS
RETURN @newkey
-----------
and... more >>
DTS from Excel problems
Posted by bagman3rd at 3/17/2005 1:41:03 PM
I am trying to import an Excel spreadsheet into SQL Server. Why can I import
an empty Excel column only if it is a text field? If the field is a number
or date field, I get a conversion error.
i.e.
create table labresults
(
analyte varchar(50),
sampledate datetime,
result numeric(19... more >>
DTC (C!) fails on same server
Posted by John Beatty at 3/17/2005 1:06:27 PM
Is it a known issue that DTC will fail using SQL OLE defined links from and
to the same server? If I change servers within the link properties all is
well. If I link to myself, or another instance on myself, this is what I
get:
Server: Msg 7391, Level 16, State 1, Line 1
The operation could... more >>
FOR XML
Posted by Denis at 3/17/2005 12:57:02 PM
Hello
I'm performing a query against a db with "for xml auto, elements" clause
Something like
Table
Field 0 Setas Primary Key
Field 1
Field 2
SELECT field1, field2 FROM table FOR XML AUTO,ELEMENTS
If I run the query into Query Analyzer I get the result I aspect
<table>
<field1>v... more >>
BCP and column defaulting
Posted by Viji at 3/17/2005 12:32:14 PM
I am bringing data from a file using bcp as below in a stored procedure.
SET @SQLString = 'BCP STAGING IN "' + @file_path + '" -c -F2 -Uxyz -Pxyz'
EXEC master..xp_cmdshell @SQLString
The table has only one column varchar (1024). I need to add one more column
called code which i can pass to... more >>
DTS Fails using links to same server
Posted by John Beatty at 3/17/2005 12:04:15 PM
Is it a known issue that DTS will fail using SQL OLE defined links from and
to the same server? If I change servers within the link properties all is
well. If I link to myself, or another instance on myself, this is what I
get:
Server: Msg 7391, Level 16, State 1, Line 1
The operation co... more >>
Temp Tables - Problem refrencing added colums
Posted by Guy Hall at 3/17/2005 11:43:11 AM
Hi,
I have an sp that creates temptables. I then add an identity column using
alter table #Surcharge add [id] int identity(1,1) NOT NULL
alter table #Extras add [id] int identity(1,1) not NULL
If I
Select * from
the tables I can see the new column but if i try to reference it
select ... more >>
Batch execution
Posted by Rick at 3/17/2005 11:11:03 AM
Hello All,
I have a table TableX with one column SQL varchar(8000). This column
contains about 50 records (rows) like
insert into tablename1 select datetime,...From Tbl1 Where....
insert into tablename2 select datetime,...From Tbl2 Where....
insert into tablename3 select datetime,...From Tbl... more >>
Stored procedure performance Question
Posted by BenM at 3/17/2005 10:57:12 AM
Using SQL 7: I have written a stored procedure which has significantly
decreased query time. It is a straight-forward query.
Anyway, at times it performs like a champ, and there are times when it runs
as slow as the normal query, or slower. The system usage is the same at
either instance... more >>
Get Linked Server Dynamic Output ?
Posted by xenophon at 3/17/2005 10:39:05 AM
I am accessing a Linked Server. I create a #temp table
with appropriate columns, and then put data into it
like this:
Exec RemoteServer.Server.Dbo.SearchSP '1' , '2'
However, the column names and schema on the linked
server changes and I have no control over it.
Wha... more >>
Stored procedure stuck in locked [compile] status
Posted by tthrone at 3/17/2005 10:25:06 AM
I am trying to run a stored procedure that calls another stored procedure
from within. The problem is that when it tries to execute the second
procedure, that procedure gets stuck indefinitely in a locked status waiting
for [compile] resource. I cannot kill it. If I try, the status says
"... more >>
Comparing two rows in a Table
Posted by Yog at 3/17/2005 10:19:02 AM
Hi Gurus,
Is there any automated way to compare the contents of TWO rows in the same
table of SQL Server ?
Thanks in advance.
Regards,
Yog... more >>
is MS SQL stored procedures re-entrant?
Posted by sxiang NO[at]SPAM student.math.uwaterloo.ca at 3/17/2005 10:06:38 AM
Greetings All:
I'm in the process of making a store procedures that generate unique
application IDs for each application form submitted into the database.
My stored procedure looks like the following:
1. Read in all existing application records
2. Find the max application ID, call it 'ID'
... more >>
Graphics and SQL-Server
Posted by Mario Reiley at 3/17/2005 10:04:01 AM
Greetings group
I wanted to expose my following case:
I have an application that uses Microsoft SQl-Server like Backend but I am
presented the following problem: I should keep and to recover in some
columns files in format Word, Excel, PDF, Text, and graphics as Autocad or
JPG.
But the t... more >>
return value from EXEC call?
Posted by Al Blake at 3/17/2005 10:03:25 AM
I need to get a value from a linked server based on a variable. To do this I
have to use an exec call (as per Q314520). The problem is I want to get the
value select by the exec call back into a variable in my Proc. How do I
make this work:
This works:
set @TSQL=
'SELECT write FROM OPE... more >>
Help with Round( ) function.
Posted by Steve at 3/17/2005 9:58:37 AM
Hi,
I am using the round function since i want two decimal places and it doesnt
give me the correct results.
The field in which i apply it is a Real with Auto number of decimal places.
In my querries I have something like:
value1 = 2.3443 and Round(value1,2) = 2.3443 *instead of* 2.34
... more >>
Restoring DBs as different names for testing
Posted by Lonnye Blake Bower at 3/17/2005 9:54:24 AM
Good morning,
There is a job that runs daily to restore the production databases to a
different server for testing purposes so that the test site can have live
data on a daily basis. There is a script that runs after the database
restore to ensure views/procedures/triggers are not referencing th... more >>
Test before update or insert?
Posted by KH at 3/17/2005 9:37:07 AM
In languages such as C, VB, Javascript, etc, testing a condition before a
looping statement, as shown below, is redundant (although I do see it
sometimes); example:
if (x < 0)
{
while (x < 0) { x += 1; }
}
With SQL, it would also be functionally redundant to surround an insert or
... more >>
delimiting the amount of rows in a DML sentence
Posted by Enric at 3/17/2005 9:25:09 AM
Hi all,
I want do a delete but defining the amount of candidate rows:
delete from table1 where sinperiodid = 200 (returning 100 rows)
I just delete the three first row of that set of results.
How?
Thanks a lot,... more >>
Permissions
Posted by JMNUSS at 3/17/2005 9:17:04 AM
Does anyone have a script that can be used to return all users granted
permission to a cretain table, it would be greatly appreciated!
TIA, Jordan... more >>
Driving Crazy
Posted by Ed at 3/17/2005 9:03:02 AM
hi,
There is something i really don't understand.
There is a remote server shows under Security --> Remote Servers
and I just cannot delete it.
I run sp_dropremotelogin -->
it said "There are no remote users mapped to any local user from remote
server 'repl_distributor'
I run sp_dropse... more >>
limiting the number of record sets returned by a stored procedure
Posted by George Tihenea at 3/17/2005 8:53:01 AM
Hi,
I know that a stored procedure will return as many results sets as
SELECT statements are in. I want to actually mark which selects should be
returned as results sets and which are just internal. Is there a way of
doing this?
Thanks,
George.
... more >>
Remove leading zeros?
Posted by Fetty at 3/17/2005 8:48:09 AM
I need to compare 2 fields, but the one field has zero's in the front of
the
number???
0000872509 to 872509
SELECT tblTenureMaster.PersonnelNumber,
dbo.tblDIMHREmployee.HREmpEmployeeNameLast
FROM tblTenureMaster INNER JOIN
dbo.tblDIMHREmployee ON
tblTe... more >>
Loops in stored proc or webcode? Which is most efficient?
Posted by Roy at 3/17/2005 7:15:10 AM
Apologies for the cross-post, but this truly is a two-sided question.
Given the option of creating Looping statements within a stored proc of
sql server or in the code-behind of an .net webpage, which would you
choose and why?
Reason I ask is I created a webpage which essentially runs throug... more >>
System tables maintenace
Posted by Enric at 3/17/2005 5:11:06 AM
Fellows,
I ask myself how many system tables are capable of be deleted (i mean, the
contents, of course).
For instance sysmessages apparently only contents disposable data.
Thanks a lot for your support and best regards,... more >>
Invalid dates passed to an SP
Posted by Andy at 3/17/2005 4:09:01 AM
Hi,
We have a number of SP's which have a couple of datetime params.
We expect the format to be such as 'YYYYMMDD' to get around the issue of US
vs UK dates. Unfortunately if an invalid date is passed, it errors straight
away with (e.g.)
Server: Msg 8114, Level 16, State 4, Procedure usp_Ge... more >>
Adding a Linked Server.
Posted by Patricia at 3/17/2005 3:49:03 AM
Dear all,
I am doing the following code
EXEC sp_addlinkedserver
'MYSERVER',
N'SQL Server'
GO
And getting this error
Server: Msg 18452, Level 14, State 1, Line 12
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
What am I doing w... more >>
Inserting into Different Server Error
Posted by Julie at 3/17/2005 1:07:01 AM
Dear All
I am trying to do the following code...
insert into [SERVER].MyDatabase.dbo.MyTable (Param1, Param2, Param3)
values (1, 1, 1 ), however I keep on getting the message
Server: Msg 7411, Level 16, State 1, Line 1
Server 'SERVER' is not configured for DATA ACCESS.
Can anyone tel... more >>
Convert string to hex to int
Posted by male hit at 3/17/2005 12:20:29 AM
My table has some hexadecimal data but stored as string. I want to
convert this to hex and then to int. How do I do this?
Data in my table:
139D5
6374
63B2
620B
ABC7
6391
6FA6
604A
139D6
This should be ideally
0x139D5
0x6374
0x63B2
0x620B
0xABC7
0x6391
0x6FA6
0x604A
0x139D6
... more >>
|