all groups > sql server programming > april 2004 > threads for thursday april 22
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
Detect Update done with table have timestamp.
Posted by A.Fish at 4/22/2004 11:01:06 PM
Hi
I had a table with column of timestamp to do concurrency control. The Update storedprocedure is as follow. How should I detect if error happen on updating? I got @@Error = 0 and @@Rowcount =1 everytime even update fail. Please help
UPDATE Customers SET CustomerID = @CustomerID, CompanyName = @... more >>
Found a bug - is it known? can others reproduce it?
Posted by Hugo Kornelis at 4/22/2004 10:30:22 PM
Hi,
Today, I encountered a bug in SQL Server. My database is quite complex
so it took me quite some time to trim off everything that is not
directly related. I am still left with a long repro script (down
below).
First: the offending query:
SELECT *
FROM Vi... more >>
Trying to pick database object naming standard
Posted by Ivan Demkovitch at 4/22/2004 10:09:00 PM
Ok... I'm starting new project and brainstorming all ways to name objects
(tables, columns and procedures)
I've read thru newsgroups and like idea about sp's where I name it like:
XXXX_A_Name
Like SYST_I_User and so on
However, I have hard time picking standard for tables.
In a ERP pac... more >>
MS SQL Programming Book
Posted by Brian Candy at 4/22/2004 9:20:49 PM
I just can't find a book that will teach me how to program Stored
Procedures. I am very confident with VB6 and .NET, and am just looking for
something that will teach me SQL Server 2000 programming. I have a limited
ability, but want utilise stored procedures an awful lot more.
There are a cou... more >>
Performance of queries against Linked Server
Posted by Kayda at 4/22/2004 7:41:23 PM
Hello:
I have SQL Server 2000 running on my laptop and have created a linked server
against a Sybase database that I am accessing through a VPN connection.
When I run a query from Query Analyzer connecting to the linked server the
query takes 27 minutes to run. When I run basically the same ... more >>
Matching field values across 2 tables
Posted by bob_whale NO[at]SPAM yahoo.com at 4/22/2004 7:08:16 PM
This one is not straight forward as the subject line, but I'd love to
get some responses.
The scenario: client side user answers a few quiz questions via web
interface and the results are submitted to the db for evaluations and
processing of cumulative data. The catch is that each question can... more >>
temporary table Vs variable table
Posted by Bahareh Sarvani at 4/22/2004 6:06:53 PM
what's the difference between Variable table and temporary table?
when we should use the first one and when the seconde one?
... more >>
Recursive query ?
Posted by KK at 4/22/2004 5:17:12 PM
Hi,
I have an existing databse whose structure is like below
ID ChildrenID <-- varchar field
10000 10001,10002,10003,10004
10001 /*Allways there are 4 */
10002 /*children per ID (MAX 4)*/
10003 10004,10005,10006,10007
... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
turn off parallelism for the stored proc level
Posted by Kuang Zhang at 4/22/2004 5:16:03 PM
I have a very large stored proc that is deadlocking on itself. Base on our test we think its due to the parallelism settings. Is there a good way to turn off parallelism for the entire stored procedure.
I have looked at MAXDOP (on the SQL Statement level
and "max degree of parallelism" (will ef... more >>
How to backup and shrink a database from a DTS?
Posted by Learner at 4/22/2004 5:08:07 PM
Hi,
How can I shrink and then backup a database via a DTS.
Can you kindly guide in a step-wise manner please.
Thanks.... more >>
merging data
Posted by Michelle McElvain at 4/22/2004 4:56:03 PM
I have a CSV text file that I'm being asked to import into a SQL database. No problem there, except two of the columns need to be merged into one, or rather the 2nd column needs to append to the 1st. I can't seem to figure out how to do this with SQL-Transact. I'm a beginner at this and would apprec... more >>
DTS, vbs & identity insert?
Posted by spam[at] at 4/22/2004 4:49:26 PM
Hello,
I'm trying to create a vbscript for a DTS import package. The field: 'Record_ID'
is an identity column, how do I insert the next identity value using vbs?
Function Main()
' DTSDestination("Record_ID") = next identiy value?
DTSDestination("Title") = DTSSource("Col001")
DTSDestina... more >>
Transact SQL statement question
Posted by j.m.autry NO[at]SPAM earthlink.net at 4/22/2004 4:17:12 PM
I need to query a table for the latest revision of data ( The table
holds all revs of data describing different parameters) How can I
generate an SQL statement which only retrieves the latest rev of each
parameter?
eg.
TableX
Parameter data revision
Parm1 data 1
Parm1 data 2
Parm... more >>
Building a matchkey
Posted by Nigel Quiggin at 4/22/2004 4:13:18 PM
Hi all
This is probably a bit noddy, but just about covers my level of experience.
I need to create a matchkey based on a single address column, but with all
spaces and vowels stripped out.
For example, "2881 Arlington Road" needs to return "2881RLNGTNRD"
Coding suggestions in T-SQL would... more >>
Concurrency issue
Posted by j.m.autry NO[at]SPAM earthlink.net at 4/22/2004 4:11:25 PM
I use an artificial primary key (an index) in a table which is
incremented from the maximum detected value in a table for the next
added item. Unfortunately, if someone else writes records between my
getting the old max index key and storing the new index key, I get a
duplicate primary key viol... more >>
Check Constraint ##-##-##
Posted by Andrew Cancri at 4/22/2004 4:00:14 PM
Hi all,
I'd like to create check constraint for codes. The constraint should allow
all these codes:
1/2/3
10/10/10
10/1/10
NN = [0-9] or [0-9][0-9]
Due to business rules, the code cannot be 01/... :(
Is there any (elegant) way?
Thanks Andrew
... more >>
If the else statement inside stored procedure
Posted by Arjen at 4/22/2004 3:58:59 PM
Hello,
I want to put this inside the "if"
//-------------------------------------------------
SELECT
ItemID,
Title,
Header,
(..)
SELECT
COUNT(ItemID)
(..)
//-------------------------------------------------
And here something for the "else"
//--------------... more >>
Linked Servers and remote logons
Posted by Thomas Scheiderich at 4/22/2004 3:53:40 PM
How do I tell who is logged on and can I see the detail (local and
remote logon)?
When I drop a linked server (trying to get it to connect properly), I
get an error that says I still remote logons. On Sql Server 7, it still
deletes the server but tells you that you have one logged on. On ... more >>
in vs. exists
Posted by chris at 4/22/2004 3:10:57 PM
sql2k sp3
Should these 2 queries produce the same results?
select count (*)
from Customer
where not exists
(select CustomerKey
from TransDTL
where PostDate between '1/1/2004' and '3/31/04 23:59:59'
and TranCode not in ('7017', '7015', '7011')
and CardActivationDate is not null)
selec... more >>
transaction within a transaction
Posted by JT at 4/22/2004 2:16:53 PM
how does sql server handle a transaction within a transaction???
... more >>
query from different DB in Query ANalyzer
Posted by Rafael Chemtob at 4/22/2004 2:08:00 PM
hi,
I have 2 different databases on the same SQL server.
I want to query from database A the values in a table for database B.
I tried to do this
select * from databaseA.tablename
doesn't work,
any ideas?
thanks
... more >>
Order By NEWID() and Sorting by another field.
Posted by bleh at 4/22/2004 1:51:49 PM
i need to query a DB and select the TOP X random records and then need to
sort those selected records by another field.
any ideas?
Thanks!
bleh
... more >>
CASE perform boolean evaluation in where clause?
Posted by Ian Boyd at 4/22/2004 1:38:07 PM
Is there a syntax to allow the following concept?
SQL Server complains: "Incorrect syntax near '='."
SELECT * FROM Table
WHERE (
CASE CorporateStructureType
WHEN 1 THEN (CorporateStructureID = @DivisionID)
WHEN 2 THEN (CorporateStructureID = @DepartmentID)
WHEN 3 THEN (Corpora... more >>
Retrieve object ID/name of table inside a trigger
Posted by Sven Brandt at 4/22/2004 12:47:08 PM
Hello,
i need some help. I want to retrieve the object id or the name of the table
in which the trigger was fired. Does anybody know how to do this inside the
trigger ?
Regards
... more >>
Forcing casesensitive in a search with a caseInsensitive database.
Posted by Craig Kenisston at 4/22/2004 12:31:02 PM
Hi
I have a database which is setup with CaseInsensitive
But I have to run a search for a field that I want to be checked with case sensitive, in other to return a user's error
Select * From MyTable Where MyCaseSensibleField = @MyStringParamete
For example, if I have stored the value "Ax" an... more >>
Select 10/3 = 3
Posted by Doru R at 4/22/2004 12:29:12 PM
Hi,
When selecting an expression based on an integer like
Select 10/3 the result is an integer, 3. What if I need the decimal part
too?
Thank you,
Doru
... more >>
deadlock
Posted by ms at 4/22/2004 12:18:48 PM
I'm studying about DBMS, I have uncertain understood about deallock. Could
any one give me more information, some materials or explanation about those
problems. It seems better to give an example (SQL server).
Thanks so much.
... more >>
using "result table" from SQL EXECUTE call to stored proc.
Posted by roger_beniot NO[at]SPAM yahoo.com at 4/22/2004 11:57:23 AM
If I have a stored procedure that generates a table of information how
I can leverage that table w/ subsiquent stored proc calls.
Basically I want to do the following:
EXEC sp_SP1
-- Do something with the table?
EXEC sp_SP2
Currently SP1 returns the correct table/info, but I cannot... more >>
Update statement
Posted by Jose Valle at 4/22/2004 11:54:38 AM
I have a table that had a column named [data] that contained a big bundle of
data like this.("Status=Mapped To Logfile Share; sn=3J28LCV1309M; mk=Compaq
Evo N610c; sv=WinNT; os=Windows_NT; sp=Service Pack 1; bl=2600; cv=5.1;
vb=5.6; tg=5.5.402.0; ag=5.5.402; ie=6.0.2800.1106,SP1,Q810847,... more >>
concatenate two tables
Posted by C#User at 4/22/2004 11:21:45 AM
hi,
I have two tables which all have the same fields and i want to combine
them together, how can i do it. I cannot use select ... into.
I appreciate your help!
... more >>
Debugging triggers
Posted by Igor Solodovnikov at 4/22/2004 11:07:36 AM
Hi,
If i put some PRINT statements in trigger code where can i see theirs
output?... more >>
Join Date fields w/Diff data-type
Posted by J. Joshi at 4/22/2004 10:50:19 AM
Hello all,
I have a query where I want to find records based on a
ServiceDate field and CustID that does not fall between
the CoverageStartDate and CoverageEndDate fields.
The problem is the ServiceDate field is displayed as 2003-
05-05 09:56:00.000 and the CoverageStartDate &
Coverag... more >>
Using information_schema...
Posted by William Morris at 4/22/2004 10:42:19 AM
I would like to run the following query (or something like it) and return
only tables. Currently, it also returns views. Anyway around that?
select table_name, column_name
from information_schema.columns
where column_name = 'contactid'
and table_catalog = 'seamlyne'
Thanks!
--
Willi... more >>
third normal form
Posted by joe at 4/22/2004 10:40:18 AM
can someone explain to me term of "third normal form"
in a few "brief" sentences? It's one of tricky interview questions bother
me.
... more >>
Pivoting query results
Posted by David Morrison at 4/22/2004 10:27:54 AM
I have a table that looks like this:
GroupA CodeA GroupB CodeB Amount Index
Territory 100 State CO 500.00 101
Null Null State CA 750.00 102
Territory 200 Null Null 300.00 103
I'd like to query this table to return results th... more >>
transactions on reads?
Posted by Daniel Billingsley at 4/22/2004 10:25:05 AM
I'm trying to fully understand the concept of using a transaction with Read
Committed isolation for a select query.
I think I understand the basics of how it protects you from dirty reads.
However, I'm wondering about the practical reality.
*The base question is do I really want to slow down... more >>
how to loop
Posted by C#User at 4/22/2004 9:59:54 AM
hi,
I have the following table:
Table1:
customerID BatchID
1 123
2 234
1 124
and I have a store proc getSingles
Exec getSingles '123' will reture a list of records.
My question is how to get all the records of one custom... more >>
Set collation of all column to default
Posted by Stijn Verrept at 4/22/2004 9:58:53 AM
Is there an easy way to set the collation of all columns of a database
to default?
--
Kind regards,
Stijn Verrept.... more >>
Row Number in SQL Server
Posted by Scott Meddows at 4/22/2004 9:40:16 AM
I'm looking for a way to put a sequential number in a query;
i.e.
Counter DataField1 DataField2
1 23 43
2 19 29
....
30 302 102
31 143 2
than... more >>
century of a year
Posted by eli at 4/22/2004 9:11:06 AM
Is there any function to get centur
something similar to datepart(yy,getdate()
Thanks
... more >>
set with a select ?
Posted by Steve in NJ at 4/22/2004 8:56:04 AM
Why can't I do the following
declare @a numeric(13,2
set @a = select [Amount] from #bottom_line where [Description] = 'Budget'
I want to store values in variables, do some math, and then insert my results
Please point me in the right direction. Thanks.... more >>
totals into the temp table
Posted by Steve in NJ at 4/22/2004 7:21:05 AM
I have 3 tables that I run totals on. I want to put the totals in a temp table - 3 separate fields - and then select the record from the temp table as a report. How do I get the totals into the temp table? Thanks.... more >>
Problem with transactions
Posted by Jamie at 4/22/2004 6:42:09 AM
I was run follow command in two Query Analyzers
1. In 1. Query Analyzer:
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
BEGIN TRANSACTION m1
update mytable set name='newname' where idtable=2
2. Open 2. Query Analyzer and exec SQL:
select * from mytable
3. in 1. Query Analyzer:
COMMIT... more >>
Remove trailing little square
Posted by hngo01 at 4/22/2004 6:13:49 AM
How can I remove the trailing little squares in my table?
... more >>
Hidding user tables
Posted by Jane at 4/22/2004 5:38:33 AM
Hi,
Is there any provision to change user
table/procedures/jobs to System Table/procedures?
or else
Is any solution to my tables/procedures/jobs can not
visible on Enterprise manager
But it can do their work
Advance love for giving solutions... more >>
Cursor Performance
Posted by Chai at 4/22/2004 5:31:04 AM
Hey,
I Have 600 Views Which i Need To Insert To a One Table,
The Method I Chose Is To Prepare The List
Of all Views Using Sysobjects Table,
And then running with cursor for each view in the list.
The Performance is not to good,
and im looking forward for anothet solutions
Which achieve bet... more >>
Default of Param on a SP
Posted by Konstantinos Michas at 4/22/2004 5:28:19 AM
Hello Experts,
How can I get the Information that a parameter has a
default value or not?
The sp_procedure_params_rowset doesn't return this info
correct.
Thanks in advance.... more >>
How to create files/folders
Posted by kamal at 4/22/2004 4:54:16 AM
I need to create a file(Path) and Need to transform one or
more table data into that text file. from stored procedure
Any article or solution regarding thanks in advance... more >>
Indexes
Posted by Jonathan Derbyshire at 4/22/2004 4:21:14 AM
Hi
I'm aware that in Oracle, If a query will be returning more than 15% of rows, a full table scan will always be used (rather than any indexes). Is this true of SQL Server 2000, or will indexes always be used, regardless of the query? (Not using any Hints)
Thank
JD... more >>
Like operator making query behave strangely
Posted by Sky Fly at 4/22/2004 4:13:57 AM
Hello,
I have a query which retrieves data from two tables, SmallTable
and BigTable. The table definitions are as follows:
SmallTable
(
small_field varchar(255)
)
BigTable
(
big_field varchar(255)
)
SmallTable only has two to three rows, so it doesn't have any index;
BigT... more >>
Pivot Query
Posted by Stelios at 4/22/2004 3:39:58 AM
Hello Gurus,
I got 2 tables and I want to combine there data:
Select 1 EmplID, 'Job' Type, 'Athens' City, 'Greece'
Country, '3223123' PhoneNum Into #Contacts
Union
Select 1, 'Home', 'Chalkida' City, 'Greece'
Country, '2222224' PhoneNum
Select 1 EmplID, 8 WorkHours into #Employees
S... more >>
Insert into multiple tables
Posted by DBA72 at 4/22/2004 3:36:03 AM
Is there any way to insert data into two tables (without creating a view on both tables). I am migrating data and need to insert data into the new table and a mapping table as well. I am trying to avoid using a cursor to do this
Thanks... more >>
Bug in Enterprise Manager when you Paste into EM
Posted by Panos at 4/22/2004 1:46:05 AM
Hi
I've noticed that EM is inconsistent when modifying data. Say that you open a table from EM so you can modify fields etc.
Now run a query in Q Analyzer and select a cell. Say that you want to copy that value from QA to EM so you do Ctrl-C Ctrl-V into EM. Now this is what I got for my table..
... more >>
Trigger Timing
Posted by JT Lovell at 4/22/2004 1:15:00 AM
I have a third party app with an email table and a related attachment =
table. There is a basic FK relationship, and no other constraints.
A third party app drops records into the email table and any attached =
files into the attachment table related the email. I need to write a =
trigger to... more >>
|