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 2005
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 Select First Record when we have duplicate records
Posted by Tenzeel at 3/31/2005 10:59:03 PM
Hi All,
How to Select the "First Record" from the Table when we have duplicate
values. and we dont want to see the duplicate values.
Scanario.
i have Company and Address Table,
Company_id is the foreign key in Address table.
one company can multiple addresses.
plz guide me how i can select t... more >>
what will be really locked by a holdlock?
Posted by nonno at 3/31/2005 10:57:02 PM
hi, I have a few questions about holdlock, e.g.
begin tran
....
select @last_val = max(col1) from table1 (HOLDLOCK) where col2 = 'X'
....
insert table1 (col1, col2) values (@last_val + 1, 'X')
....
commit tran
What will be locked here (the entire table1 or only the rows with col2='X') ?
Wil... more >>
Tables last accessed
Posted by William F. O'Neill at 3/31/2005 9:39:59 PM
I would like to know if I could find out the date a table was last accessed.
If so, could you give me some script to do this?
... more >>
question about retrieving identity value
Posted by nonno at 3/31/2005 8:49:02 PM
hi,
according to the SQL Server Books Online, there're 3 system functions return
last-generated identity values: IDENT_CURRENT, @@IDENTITY, and
SCOPE_IDENTITY. My colleague wrote a stored procedure like the following:
....
BEGIN TRAN
....
INSERT INTO [TABLE_WITH_IDENTITY_COLUMN] ...
SET @I... more >>
missing statistic
Posted by Ed at 3/31/2005 6:39:14 PM
Hi,
when i run a stored procedure with the Display Execution turned on, some
of the table scan/index seek icons are in the color of red. I know that is
becuase some of the tables are missing statistic, however, all showing the
color of red are temp tables that are created inside the stored... more >>
round date
Posted by JFB at 3/31/2005 5:51:58 PM
Hi All,
Maybe this is easy but I can't find the way to fix this.
I want to get total and number of orders for each date. I use this query...
SELECT cast(o.orderdate as smalldatetime) , sum(od.unitprice), count(*) as
counter
FROM Orders o
INNER JOIN orderdetails od on
o.orderid = od.order... more >>
Scheduling stored procedures with MS SQL 2000?
Posted by wrytat at 3/31/2005 5:41:03 PM
Is there anyway to make MS SQL Server 2000 perform some stored procedures,
say 3 times a day? If so, how? They told me to go to Management->SQL Server
Agent-> Jobs. But for writing the steps, does a stored procedures belong to a
"Transact-SQL Script" type? Is there any documents or examples av... more >>
Is it possible to execute DTS in SP?
Posted by Atenza at 3/31/2005 5:38:37 PM
Hi, i have a DTS then generate a CSV file, is it possible to execute the DTS
within a stored procedure?
Moreover, is it possible to dynamic change the current database in SQL Query
Analyzer by execute a Transact-SQL? As i know,
Use DB1 <== this command can change the current database
but is... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Cursor question
Posted by danlin at 3/31/2005 5:37:04 PM
I have a table with the following columns Parent_Part (PP), Child_part (CP),
Need_Date (ND), Reqd_qty (RQ), QTY_On_Hand (QOH). QOH is total qty in stock
that has been reserved for the parent part and is to be allocated to the
child based on the need date per PP/CP group. The sample table loo... more >>
execute SQL file from SQL Server
Posted by Vince
hello!
is it possible to execute SQL script flat file from SQL Server? I
guess yes, but couldn't find the way for that...
any idea?
thanks.
Vince
++... more >>
**** Need Help in setting OPENQUERY() with linked servers ****
Posted by sydney.luu NO[at]SPAM gmail.com at 3/31/2005 4:49:16 PM
Hello!
I'm a newbie running queries against linked servers. Someone had
already
setup the linked servers in SQL2000 to go access AS400/DB2 and ORACLE
tables.
Let's say there is linked server in SQL2000 called "MyLinked_AS400" and
I have
the following tables in which I need to retrieve da... more >>
passing table name into a stored procedure
Posted by softengine at 3/31/2005 4:47:02 PM
Is it possible to write is a stored procedure that passes a table name into a
stored procedure?
select * from @tablename
... more >>
Updateable query
Posted by David C at 3/31/2005 3:52:15 PM
I have an Access application that uses ODBC connections to SQL 2000
database. I have 2 Access queries that each have 2 tables linked on PK on
one and FK on another. One of the queries is updateable and one is not. I
cannot figure out the difference. Can anybody advise? Thank you.
David... more >>
Re:grant permission on function
Posted by Hari Prasad at 3/31/2005 3:01:48 PM
Hi,
Give EXEC permission to the function.
GRANT EXECUTE ON FN_NAME to USER_NAME
Thanks
Hari
SQL Server MVP
____________________________________
Britney Wrote:
hi all,
i know you can grant permission for function by the following code:
grant all on GetEmployeeName to user... more >>
grant permission on function
Posted by Britney at 3/31/2005 2:47:10 PM
hi all,
i know you can grant permission for function by the following code:
grant all on GetEmployeeName to user1
but how can I grant just SELECT permission on Function GetEmployeeName()?
... more >>
Subquery evaluation!
Posted by Aleksander Tu¹ek at 3/31/2005 2:28:26 PM
Hello!
Compare this two queries:
USE NORTHWIND
GO
DECLARE @TMP Table (CustomerID VARCHAR(10))
INSERT INTO @TMP (CustomerID) VALUES ('CACTU')
INSERT INTO @TMP (CustomerID) VALUES ('ANTON')
INSERT INTO @TMP (CustomerID) VALUES ('BONAP')
select * from customers
where customerID in ... more >>
a
Posted by Ahmad Jalil Qarshi at 3/31/2005 2:27:15 PM
Troubleshooting debugging set up for VS.NET vs. remote SQL server
Posted by Mark Murphy at 3/31/2005 2:25:11 PM
I'm trying to step into a stored proc on my client development machine. The
sproc is in a database on a remote sql server machine. On the client side,
nothing happens when I step into the sproc. On the sql server side is the
event log message that follows. I've been through all the dcom se... more >>
Combine Add/Edit SP's?
Posted by Dan at 3/31/2005 2:19:06 PM
Rather than having 2 separate stored procedures to add and update something
like a customer record, are there any drawbacks to having one stored proc
that does both? If the custID is passed in, then it would do the update, and
if the custID param is NULL than it would do an insert. Would this ... more >>
will the money data type ever change?
Posted by Bob at 3/31/2005 2:06:45 PM
After many years of trouble-free operation, Accounting now tells me that
they need to store more precise prices; there are actually cases when we're
buying things that cost $.01895 per unit. I'm going to have to switch to
Decimal, but I was just wondering if the precision of the money data type i... more >>
Column Name
Posted by MS User at 3/31/2005 2:00:56 PM
SQL 2K
I ran the below sql to list the table name and column_name with column_name
like 'ID'
select substring(so.name,1,50) 'Table Name',
substring(sc.name,1,50) 'Field Name'
from sysobjects so
inner join syscolumns sc on
so.id = sc.id
where so.type = 'U' and
sc.name like '%ID%'
order... more >>
compiling objects to multiple databases
Posted by BL at 3/31/2005 1:55:03 PM
Anyone have any suggestions they could share on compiling objects to multiple
databases at the same time on the same server and also to multiple servers?
Example:
Stored procedure needs to be compiled on 60 databases on the same server.
Thanks for any help!... more >>
Query hangs during a seperate write
Posted by Joe at 3/31/2005 1:28:46 PM
When writing 100's of records to 1 or more tables within a transaction, the
server seems to hang any query trying to read from those tables until either
a Timeout or the write process completes. I'm not doing a lock.
The writes and reads are separate applications.
What would cause this?
... more >>
Performance Problem
Posted by Richard Douglass at 3/31/2005 1:23:47 PM
I am experience a very strange performance problem. A nightly job that had
been consistently running 2 hours each night is suddenly running 16 hours.
A trace reveals a section of code taking 2500-3800 milliseconds of CPU to
process. The execution plan for the select statement shows the indexes ... more >>
Collation conflict
Posted by simon at 3/31/2005 1:23:30 PM
I have 2 servers, both of them have the same collation.
Then I create temp table on 1st server:
create table #tmpNovi (country char(3) COLLATE database_default ,datum
datetime)
Then fill the table.
Then I join this table to second server:
select s.* FROM
[SERVER2].[DW_Temp].[dbo].[... more >>
question about designing big tables...
Posted by === Steve L === at 3/31/2005 1:08:36 PM
sql2k.
i'm preparing a sql table with 125 fields (columns) to import a huge
text file. i have calculated the max length needed for each of the
field.
but when i issued the create the table statement, i've got the
following message:
Warning: The table 'loc' has been created but its maxi... more >>
Return value vs. record count
Posted by Richard at 3/31/2005 1:01:07 PM
I'm using VB.Net in an ASP.Net web app to insert/update a record in SS 2000
using stored procedures. I'm using the SQLCommand object to perform
ExecuteNonQuery: retval = cmd.ExecuteNonQuery()
Currently the sp returns the number of rows affected into retval, so I know
if it returns 1 then 1 ... more >>
possible Scope_Identity() problem
Posted by Jo Inferis at 3/31/2005 12:24:58 PM
I have an ASP.NET application with a SQL Server 2000 backend, where two
pages fire off two different stored procedures. Each stored procedure
creates a new record in a particular table then uses Scope_Identity() to get
the id of the newly created record for adding it to a link table. The
problem... more >>
Incorrect syntax near the keyword IF
Posted by Keith at 3/31/2005 12:21:02 PM
I am writing a user defined function and I get the Error 156: Incorrect
syntax near the keyword IF. My function looks like this
CREATE FUNCTION dbo.func1(@var1 varchar(64))
RETURNS @MaintCost TABLE (@result1 varchar(64), @result2 varchar(64),
@result3 varchar(64))
AS
IF @var1 = 'I'
... more >>
Newbie Question
Posted by J Abrams at 3/31/2005 12:07:35 PM
I am trying to sum some data in a table, and I can't figure it out. Below
is some sample data
Date,Customer,Order_Amt,Paid_Amt
2004-10-02 00:00:00,101,1418.82,-1400.00
2004-10-02 00:00:00,101,265.21,-200.00,
2004-10-02 00:00:00,101,648.74,-648.74
2004-10-02 00:00:00,102,95.95,-95.95
2004-... more >>
linked server msdb stored procedures
Posted by Larry Storm at 3/31/2005 11:59:27 AM
exec [ltd-gln-db2].msdb..sp_help_job
exec [ltd-gln-db2].msdb..sp_help_alert
Neither line fails.
The first returns 0 rows.
The second returns > 0 rows.
Both stored procedures allow 'public' to 'exec'.
Question: Why does sp_help_job return no rows?
Note: SQLServer 2000 SP2 on all db serve... more >>
Re:When was an SP last run?
Posted by Hari Prasad at 3/31/2005 11:54:42 AM
Hi,
The only way is by enabling the SQL Profiler trace.
Thanks
Hari
SQL Server MVP
____________________________________
Andy Wrote:
Hi,
Is there a way of finding out when an SP was last run?
I guess some clues may be in how old the query plan is, but even this isn't
really what... more >>
Re:SQL Server MVP ?
Posted by Hari Prasad at 3/31/2005 11:44:19 AM
You can become an MVP by doing :-
1. Writing Articles on Microsoft technologies (SQl Server)
2. User Group activities in your local microsoft group
3. Conductiong Training / Seminars in Teched, User Groups,...
4. Answering Microsoft SQL Server news group
see the below link for more info
... more >>
sp trace is not outputing any data
Posted by Sai at 3/31/2005 11:41:20 AM
following is the code I used to create the trace,
/****************************************************/
/* Created by: SQL Profiler */
/* Date: 03/31/2005 01:53:11 PM */
/****************************************************/
-- Create a Queue
declare @rc... more >>
Newbie: date-time help
Posted by steve at 3/31/2005 11:29:21 AM
Hi,
I have created a date_time field that, as the name suggests, contains both
day and time info (02-03-2002 12:00:32)
How can i query both the time and day?
i tried :
......
WHERE
date_time > "12-02-98 00:02:23" and doesnt seem to work.
Also, is there a way I can "isolate" the day and... more >>
havinx max data problem
Posted by Björn at 3/31/2005 11:26:41 AM
Hi group
I have a table with 3 Columns
ID REF_ID START_DATE
1 10 01.01.2005
2 10 01.02.2005
3 11 01.01.2005
4 12 01.02.2005
5 12 01.10.2005
Now I want to select the ID´s where the REF_ID is ... more >>
OpenRowSet Excel 255 Length Issue
Posted by douglaae NO[at]SPAM hotmail.com at 3/31/2005 11:21:34 AM
Hello all,
I have an Excel spreadsheet that I'm trying to import into a SQL Server
2000 database. I'm using OpenRowSet to import the data and it works
great unless there is data in an Excel cell that exceeds 255
characters. When a cell contains > 255 characters, I get the following
error (w... more >>
about xp_cmdshell..
Posted by Vince
Hello there!
I'm using xp_cmdshell in a loop to write in a file...
do you know better way to improve effiently writing on disk in a loop?
or any recommandations on xp_cmdshell uses (could we switch off the
msg feedbacks ?)
thanks a lot
++
Vince... more >>
deleting all rows in table which references itself
Posted by Stephen Ahn at 3/31/2005 11:09:15 AM
Using SQL Server 2000.
The example code below shows a
table which references itself.
i.e. column "parent" references column "pk" :
==
create table table1 (pk int not null primary key, parent int null,
aname varchar(50) null)
alter table table1 add constraint fk_table1_table1
foreign ke... more >>
How can i export SP/Table through my SP ?
Posted by DMP at 3/31/2005 10:46:30 AM
Hi,
How can i export a SP/Table through user SP ?
... more >>
Errors trying to retrieve large excerpts
Posted by Enric at 3/31/2005 9:51:02 AM
hi again,
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (recv()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
[Microsoft][ODBC SQL Server Driver]TDS buffer length too large
[Microsoft][ODBC SQL Server Driver]TDS buffer len... more >>
Text conversion
Posted by simon at 3/31/2005 9:49:53 AM
I have table Products, column productName(varchar(50)) and collation on that
column is Cyrillic_General_CI_AS.
Users are from Russia and they have application in cyrilic. That is OK.
Now, I would like to export this product names to my database.
My users don't read the cyrilic text, so, I sho... more >>
sp_monitor, weird behaviour?
Posted by Enric at 3/31/2005 9:43:08 AM
Dear fellows,
When I launch sp_monitor on my local workstation (no way there is activity
there)
the packets received counters and so forth are being constantly altered.
I was wondering why.
sp_monitor
--
last_run,current_run,seconds
2005-03-31 19:39:21.140,2005-03-31 19:39:30.840,9
... more >>
Display Estimated Execution Plan
Posted by Enric at 3/31/2005 9:17:08 AM
Dear all,
I obtain a warning when I press the 'Display Estimated Execution Plan'
for the following sp:
up_Rpt_Data_Contents_Bridge_Wholesaler '2005-01-01','COW'
Server: Msg 208, Level 16, State 1, Procedure
up_Rpt_Data_Contents_Bridge_Wholesaler, Line 42
Invalid object name '#PERIODS'.... more >>
cast or convert varchar to money/datetime
Posted by Ron at 3/31/2005 8:47:11 AM
Hello,
I have a dataset that is all varchar with leading and
trailing spaces (comes from a mainframe). I import this
data to a table that is all varchar (using DTS). I then
insert it to a table that has the correct datatype fields,
but I have to perform a conversion. I have been using ... more >>
When was an SP last run?
Posted by Andy at 3/31/2005 8:29:08 AM
Hi,
Is there a way of finding out when an SP was last run?
I guess some clues may be in how old the query plan is, but even this isn't
really what I'm after.
Many thanks for any ideas.
Andy... more >>
2 very general questions
Posted by Bob at 3/31/2005 8:24:38 AM
Hi folks!
Anybody got a realy quik definition of parallelism? Is it good?
What are statistics? I did some research on the topic but bol doesn't
really tell you what they are and what to look for. I created a temp
table and put a clustered index on it, but the excution plan gives me a
warn... more >>
Queries using bitwise?
Posted by Larry at 3/31/2005 8:17:02 AM
Hi Everyone,
I've using the query below to extract some information. ONe of the items in
the where clause is a check for an integer column for 0x1.
Question: What is the correct syntax for checking this column? As below, I
have pm.ProductStatus = 0x1. This is returning rows. Am I co... more >>
SQL Server MVP ?
Posted by Richard at 3/31/2005 7:51:09 AM
How does one become a SQL server MVP? Does it only require helping/answering
questions on this newsgroup? ... more >>
HELP...Need to create query to place multiple databases offline
Posted by Richard at 3/31/2005 7:41:08 AM
Hi All,
I am currently working on a project on a sql server that has like 500
databases. I need to place like 80% of the databases offline. I have been
using dboption or EM but they are time comsuming since I have to do this one
database at a time. I have like 5 more servers with 500 databa... more >>
|