all groups > sql server programming > february 2005 > threads for wednesday february 23
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
Log Shipping
Posted by Leila at 2/23/2005 10:25:17 PM
Hi,
I finish the log shipping wizard without problem and the log backups are
created and copied to destination but they are not restored to destination
db. I use stand-by mode and make changes to source db but the changes are
not restored to destination. When I manually restore the log backups, ... more >>
looking a method to avoid user run a SP 2 times a day
Posted by souris at 2/23/2005 10:12:26 PM
I have an app to download data from mainframe daily.
I am looking for a method to avoid user run the stored procedure 2 times per
day.
I am thinking to have a SystemConfigure table to store Last_update_Date
field.
If the data equal today then do nothing, if less then download from
mainfra... more >>
Help with SP
Posted by Ed_P. at 2/23/2005 9:56:40 PM
Hello,
I have the following two tables
tb_ProductIssue
issueID productID statusID Name
============================================
1 10 1 Error 256
2 12 2 Can't install
3 10 3 Constant Reboot
tb_status
statusID status_name
1 Open
2 Closed
3 Pending
I want t... more >>
Use Column Twice, Same Row/Query, Different Data
Posted by Gary K at 2/23/2005 8:37:02 PM
Sorry that's the best subject title I could come up with, I'm not sure what
I'm trying to do would be called (except for maybe crazy & stupid).
I'm just wondering if someone has the time to comment on this.
In general, I have two tables. The first table holds a list of items that
belong to a... more >>
Running External Programs
Posted by Sue at 2/23/2005 8:35:08 PM
I've read that it can be done, but I am just a beginner and I need it in
simple steps.
What I need to do is recalculate a MS Project file when a particular column
changes.
I know how to (I think) create a trigger to start it.
I read that I need to use "Remote Stored Procedure" and "Open... more >>
Who is calling my proc AA
Posted by dev_kh at 2/23/2005 7:25:02 PM
Hi,
My database has around 2000 huge stored procedures and multiple triggers
etc. I need to find which other stored procedures are calling a stored proc
name AA (for e.g.) Is there any SQL query or a system command to find this
out. I believe sysdepends does not show all the places where... more >>
editing functions
Posted by TJS at 2/23/2005 7:15:43 PM
with msde 2000:
I can see stored prodcedures for editing and also views,
how can see a function to edit it ?
... more >>
Dataset.GetXML returns dates in ugly format:2005-01-01T00:00:00.0000000-05:00
Posted by Chad at 2/23/2005 6:14:20 PM
(VB.NET)
I created a dataset, added a table to it, and added a column of type =
DATE:
dtbMeasures.Columns.Add("MeasureDate", GetType(Date))
I then add the datatable to a dataset
dsMeasures.Tables.Add(dtbMeasures)
And pass the XML returned from the dsMeasures.GetXML() function to a =
sto... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
2 reads vs join
Posted by tshad at 2/23/2005 5:37:42 PM
I have a select that reads about 10-20 records each time and displays it on
my screen.
I now need to get one field from the master record.
Is it normally better to do 2 reads - 1 for the 20 records and then another
for the one field I need or to do a Join. Both work fine. But for the
joi... more >>
Single large join vs. multiple queries
Posted by Matt D at 2/23/2005 5:34:14 PM
I have a query that needs to get data out of 15 different tables. I've
created a single select query that joins all of these tables and it
works fine but it obviously returns dozens or even hundreds of rows.
Another way to do this would be to make multiple queries which would
return a fraction o... more >>
Group By Question
Posted by David Mroz at 2/23/2005 5:31:57 PM
I am writing a very simple polling application and I am trying to return the
results in which it will count the number of responses for a given survey.
What I wrote was:
SELECT SurveyChoice.Choice, Count(SurveyVote.FK_SurveyChoiceID) AS Quantity
FROM SurveyVote RIGHT JOIN SurveyChoice ON Su... more >>
query to list failed jobs only
Posted by Hassan at 2/23/2005 5:27:31 PM
Can i get a query to list only failed SQL Agent jobs ?
... more >>
Update statement
Posted by WS at 2/23/2005 4:51:07 PM
I need to update one temporary table with the lastbuyprice value.
The criteria for update is the matching of ItemID.
The ItemID stores inside the temporary table is something like this:
ItemIdwithnorevision Rev
A123 B
B123 NULL
C123 ... more >>
EXECuting SP within another SP
Posted by CJM at 2/23/2005 4:48:46 PM
I am trying to call an SP within another SP, but the result being returned
from the inner SP is Null, whereas I should expect it to return a 1 or 0...
Here is the code:
ALTER Proc Returns_RecordPostClean
@SerialNo int,
@LineID int,
@PostCleanDate smalldatetime,
@PostCleanResult ... more >>
How can I get the resultset from a stored procedure
Posted by Vincent at 2/23/2005 4:44:08 PM
I have a stored procedure which will output a table.
How can I use a sql statement to get the result of the sp?
Thanks a lot
... more >>
SP with Optional Parameter?
Posted by Don Miller at 2/23/2005 4:41:12 PM
Is there some elegant way for an SP with a parameter that may be populated
or not to exist without an IF...THEN construct?
For example, this is what I started with
CREATE PROCEDURE (omitted from now on)
@paramOne Int
SELECT Columns
FROM Tables
WHERE Table.ColumnOne = @paramOne
but t... more >>
end of month
Posted by romy at 2/23/2005 4:37:12 PM
hello
what is the function that calculate the number of days in a given month ?
10x
... more >>
Correlated(?) Subquery
Posted by Chris Strug at 2/23/2005 4:17:55 PM
Hi,
Quick question,
I have a table ("log") which stores transactions. It has two fields, User
and ID.
I want to update table "booking" where rows in "log" match those in
"booking".
For example, log has entries
ID User
-------------
1, USERa
2, USERb
2, USERa
3, USER... more >>
sp_rename
Posted by Ed at 2/23/2005 4:03:07 PM
Hi,
I tried to rename one of the stored procedures by using
sp_rename 'Hello', 'World'
after I execute the above command
The stored procedure name itself changed to 'World'
but when I edit the stored procedure in Query Analyzer, the text is still
Alter Proecedure Hello
as
....
....
I... more >>
How to create a view to search records between 1pm yesterday and 7
Posted by View at 2/23/2005 4:03:03 PM
How to create view to search records between 1:00pm yesterday an 7:00am today?... more >>
Trigger + updated + cursor
Posted by hoz at 2/23/2005 4:02:47 PM
Hi ,
i need some help about triggers , updated columns and cursor for an updated
table
i wrote the code shown below , doesnt work . I couldnt find my error , it
blocks sql server
-------------
create trigger ABC_Update on abc
for update
as
if update(colA)
begin
-- declarations
declar... more >>
Can't get my head around this...
Posted by cmatero at 2/23/2005 3:33:04 PM
For the following query I am trying to visualize how the where clause causes
the rankings to occur.
WHERE s.totalsales <= t.totalsales
can someone please explain this?
SELECT s.state, st.stor_name,s.totalsales,Rank=COUNT(*)
FROM (SELECT t.state, t.stor_id, SUM(s.qty) AS TotalSales
FR... more >>
IS NULL on field is not using index placed on that field
Posted by Adrian Bezzina at 2/23/2005 3:04:39 PM
Hi All,
I have the table structure as follows
->Deliveries (table)
|__OrderID (Guid)
|__DeliverDate (DateTime) (ALLOW NULLS)
Index is on DeliverDate (ASC)
60000 records
look at the query plan for the following and is using the proper index:
SELECT * FROM Deliverie... more >>
##tblTemp invisible for bcp
Posted by gok at 2/23/2005 2:57:04 PM
I did create #tblTemp on sql but can not use it with "outside" bcp routine
from command line:
Error = [Microsoft][ODBC SQL ...][SQL Server]Invalid object name '##tblTemp'.
Any idea why?
--
gok
... more >>
Unique index v. Unique Constraint
Posted by Mark at 2/23/2005 2:50:12 PM
Why would one want to put a unique index on a column versus a unique
constraint?
Thanks in advance.
Mark
... more >>
Question for an Expert!
Posted by REM7600 at 2/23/2005 2:06:56 PM
Pretend the examples below are tables... With fields (F1, F2, F3,...)
I want to take Table1 and make it like Table2 Anyone wanna venture the
SQL code?
Thanks, my skills just aren't far enough along to think it out.
Travis
FROM THIS
[TABLE1]
F1 F2
12345 VA7X
12345... more >>
What's the best book in market for DTS and SQL Programming out the
Posted by EONE4SQL at 2/23/2005 1:49:09 PM
What's the best book in market for using Microsoft DTS and SQL Programming ?
I would like to advance my skill set and become excellent with this product.
Please advise ?... more >>
Searching contents of stored procs
Posted by Andy at 2/23/2005 1:45:02 PM
Is there an easy way to search the contents of stored procedures? I am new
to the databse that I am working with and am looking for a specific table
name and want to know which stored procedures deal with that table. I can
open them all up and search through them, but with a huge number of
... more >>
User logins
Posted by PH at 2/23/2005 1:21:04 PM
Can we query sql server to see if a user is logged in?
Thanks!... more >>
how to replicate triggers?
Posted by gok at 2/23/2005 1:13:06 PM
using copy * into <temp_table> will strip all triggers, permissions and so on.
Is there a way to make a table copy on sql side with exact structure replica
wout data?
--
gok... more >>
File name as yesterday's date
Posted by Edo at 2/23/2005 1:11:03 PM
I'm running a DTS daily that needs to create a file with a unique name, as
yesterday's date. (Ex: 20050223)
I figured out how to get the date part of it:
CONVERT(char(32),DATEADD(DAY,-1,GETDATE()),112) = 20050222
but I can't seem to get it to create a table with that unique name each day. ... more >>
alternative for last()
Posted by Jason at 2/23/2005 12:27:05 PM
Hi,
Does somebody knows an alternative for the function last() in access. I've a
lot queries which uses last, but there is no alternative in sql server.
I used min/max but that did not gave me the right results. I need to know
the last row in a 1-to-many table situation.
Is there somethin... more >>
Performance benefits between a JOIN statement vs a nested SELECT
Posted by cheem at 2/23/2005 12:02:07 PM
Is there a performance bonus between these 2 sql statements?
Using JOIN:
SELECT * FROM A, B WHERE A.ID = B.ID;
Using nested SELECT:
SELECT * FROM A WHERE A.ID = (SELECT ID FROM B);
Thanks
... more >>
Next??
Posted by Justin at 2/23/2005 11:42:59 AM
I have a field stored as NTEXT(16). I need to replace some of the content in
this field. I know the replace function doesnt work.
I see there is UPDATETEXT - is this the ONLY way to do it ?? 'cos it looks
quite complicated?
thanks,
Justin
... more >>
Need some help with a Trigger
Posted by Joe at 2/23/2005 11:19:57 AM
I created an instead of insert trigger which checks to see if the "key" of
the inserted record already exists. If it does, it copies the existing
record to another table, deletes it and inserts the new one. The problem I
get is when the insert statement coming into the trigger looks like the one
... more >>
query to view current executing jobs
Posted by Hassan at 2/23/2005 10:30:08 AM
... I know i have asked this before and the response i got is run
sp_help_job.. Please bear with me as Im not a SQL guru . I would like to run
a script in QA and the output should give me the list of jobs that are
currently running. I have around 100 SQL Agent jobs on a server and instead
of ref... more >>
enumerate prepared xml documents
Posted by Oleksandr Brovko at 2/23/2005 10:21:12 AM
Is it possible to obtain list of handles returned by
sp_xml_preparedocument?
What I want is to manually release all xml documents allocated by
sp_xml_preparedocument without server restart.
At some point server runs out of memory. We might have bugs in our code(not
calling sp_xml_removed... more >>
What is difference between @ and @@
Posted by Sunny at 2/23/2005 10:18:56 AM
I am excited writing my first stored procedure. I created small stored
procedure to return total sales of given salesman and it runs in query
analyzer.
What I used in query analyzer is:
DECLARE @TotalSales money
EXEC CalculateSales @TotalSales output,'ADAM'
select @TotalSales as SalesBySal... more >>
Date format isn't working
Posted by dw at 2/23/2005 10:02:12 AM
Hello, all. We've got a table that holds the begin and end date for allowing
people into a voting app. Here's the DDL,
CREATE TABLE [tblVotingPeriod] (
[pk] [tinyint] IDENTITY (1, 1) NOT NULL ,
[beginVote] [smalldatetime] NULL CONSTRAINT [DF_tblVotingPeriod_beginVote]
DEFAULT (getdate()),... more >>
problem deleting large no. of records
Posted by sql at 2/23/2005 9:42:15 AM
Hi all,
I have a table with 6 million rows which takes up about 2GB of memory on
hard disk. So we have decided to clean this table up. We have decided to
delete all records that have syncstamp and logstamp field values less than
the value correspoing '20040131'. This will probably delete 5... more >>
Deleting rows with OPENXML
Posted by Wes at 2/23/2005 9:09:08 AM
Hi there,
I'm trying to delete some rows from a table using an xml document (in
memory) and OpenXML in SQL Server. I have the following code, but it will
only delete the first record. Any ideas?
CREATE PROCEDURE [dbo].[CompanyBusinessUnit_DeleteCompanyBusinessUnit_Delete]
@CompanyHeirarch... more >>
find available time slot
Posted by meetze NO[at]SPAM gmail.com at 2/23/2005 8:59:47 AM
I have a table that looks like:
CREATE TABLE [dbo].[UserAgenda] (
[StartTime] [datetime] NOT NULL ,
[EndTime] [datetime] NOT NULL ,
) ON [PRIMARY]
GO
and I would like to find a time gap for the amount of time I am looking
for.
For example, I want the next available hour in the list or ... more >>
Audit V2
Posted by Justin at 2/23/2005 8:52:13 AM
I am looking to write a SQL script that will show me for each table, in all
the databases on a server, which users / groups have access. In addition, I
want to break the access into whether it is SELECT, UPDATE, INSERT or DELETE
permissions.
Is this possible?
... more >>
warning: don't try this at home (or at work)
Posted by Timo at 2/23/2005 8:37:49 AM
update mytable
set content = replace(content,char(13),null)
I thought that would get rid of embedded carriage returns in my nvarchar
column.
The carriage-returns are gone, true.
:-(
Timo
... more >>
Returning intermediate results from a stored procedure
Posted by Carl Imthurn at 2/23/2005 8:32:39 AM
I am executing a stored procedure from a VB application, and would like to return
"intermediate" results from the stored procedure. Something along the lines of:
--begin stored procedure
SELECT . . .
--display "done with select" in VB app
UPDATE . . .
--display "done with update" in VB ... more >>
Solved: Columns_Updated()
Posted by joerg NO[at]SPAM krause.net at 2/23/2005 8:18:25 AM
Hi Folks,
there are a lot of messages regarding COLUMN_UPDATED() calls in
trigger here.
After a few hours I figured out how to automate the process. Because
the group helped me a lot I post the solution for further reference:
CREATE FUNCTION dbo.FN_COLUMNUPDATED (@COLUMNS_UPDATED Binary(8... more >>
Dynamic Deluxe!
Posted by Sam Davis at 2/23/2005 7:53:02 AM
I have a software system that needs to give the user to develop basically an
if statement. So IF PERSON_AGE > 15 AND MONTHLY_PURCHASE_AMT > 1000 THEN
GIVE THEM 1500 POINTS.
Here is the deal. I need to do it both during a back end process and
dynamically when a person comes to the counter. T... more >>
OT: Help with a database/application
Posted by CPS at 2/23/2005 7:38:52 AM
Hello all,
I am looking for more ideas on bullet proof style Data Bases and or
applications for my site. I possibly could do some barter trading with some
advertizing.
I need to following for the application and it should be ablet o cross
reference with other applications too.
User Name... more >>
Detecting an existence of local temporary table
Posted by Libor Forejtnik at 2/23/2005 7:36:29 AM
Hi,
I create a temporary table. for example:
create table #t1 (ID_T1 integer)
Next I would like to detect If the table already exists:
exec sp_table #t1
if @@ROWCOUNT > 0
--Table #t1 exists
else
--Table #t1 doesn't exist
But the sp_table stored proc.works only for non-temporar... more >>
Select records in a specified interval
Posted by VC at 2/23/2005 7:26:05 AM
I need to bind only 10 search results to a web page. So I need only select
10 records at a time from a table whose keys are not sequential. I know we
could pick, say, the 11th to 20th records by using a cursor to step through
the selected results. However, is there a way to do the same thing w... more >>
Update with Self Join won't parse :(
Posted by JM at 2/23/2005 7:17:05 AM
This statement won't parse, it says that "The table Crd is ambiguous". I
tried several variations, but I can't get it to work. I want to update the
Crd table from a different field in the same table with a period shift (the
period shift has been simplified for this example).
update Crd
set ... more >>
BLOB (Text) flied in Trigger
Posted by Tareq Muhammad at 2/23/2005 6:37:04 AM
Hi guys,
I have a table the contains a "text" field, I create a trigger on it to copy
the inserted record to anther indenticial table
The trigger code is:
CREATE TRIGGER Newevent ON dbo.CAL
AFTER INSERT
AS
Declare @rec VARCHAR(50)
select top 1 @REC = RECID from inserted
insert ... more >>
Scripts
Posted by Jaco at 2/23/2005 5:59:06 AM
Is there a way I can log events to a table in my database that will write a
log whenever a script is run on the database?... more >>
How to CASE a SmallInt to a Varchar value
Posted by cc900630 NO[at]SPAM ntu.ac.uk at 2/23/2005 5:26:42 AM
Why does this syntax work for bit but not for smallint ?
-- This works OK - Setting = BIT
CASE (dbo.tblAssessment.Setting)
WHEN 1 THEN 'Internal'
WHEN 0 THEN 'External'
END AS Setting,
-- This fails - error converting value 'N/A' to column of datatype smallint
-- Credit = SMALLINT
... more >>
how to select rows in a table
Posted by Vijay at 2/23/2005 4:51:03 AM
how to select rows in a table where either one of the column in the table is
having a null value... more >>
add a leading zero
Posted by Sam at 2/23/2005 4:37:02 AM
Hi all,
I have a single table with one field:
CREATE TABLE [dbo].[class_number] (
[clientpartnercode] [char] (4) COLLATE Latin1_General_BIN NOT NULL
) ON [PRIMARY]
GO
Which contains values as: 014, 015, etc. However there are also values such:
311, 281 etc. I would like to synchronise... more >>
sp_executesql
Posted by Phil at 2/23/2005 4:05:01 AM
Hi All,
Just a quick question but is it at all possible to assign the permissions of
a stored procedure to a sp_executesql statement, dont really want to go down
the road of loading the sp_executesql into a temp table or setting
permissions on the underlying tables.
Any advice would be g... more >>
bcp format file problem (Overwriting problem)
Posted by suneet Sharma at 2/23/2005 3:59:42 AM
Hi
When trying bcp with the following query :
bcp sun..testtab out dmnHeaderStatus_%_REAL_YYYYMD%.Dat /S sunTEST24 /T
-f test2.fmt -w.
I want to save my data in unicode format so i am using -w and also using
a format file test2.fmt.
When executing this i am getting -w overwrites -f and ... more >>
Export SQL Server tables to Access
Posted by madhivanan2001 NO[at]SPAM gmail.com at 2/23/2005 3:39:40 AM
Hi,
Is there any query in SQL Server2000 that will export all the tables
from Current Database to MS Access database with all data?
Thanks in advance
Madhivanan
... more >>
Database Connectivity
Posted by Jaco at 2/23/2005 2:53:04 AM
Hi
We have a application on a clients site that crashes after a while giving an
error message about loosing SQL connection. This is the only client site this
is happening on so we would asume that it has to do with the network and not
our application.
Do anyone know of a database connect... more >>
Seek method, table-direct, and sql server2005
Posted by Manuel Lopez at 2/23/2005 1:49:36 AM
From what I've read in the docs, ado.net currently supports opening sql
server ce tables in table-direct mode and performing Seek operations on them
(using SqlCeDataReader), but not on the full-blown sql server. Is this
(will this be) still true with ado.net 2.0 & sql server 2005?
... more >>
Date Datatype
Posted by Christopher Bowen at 2/23/2005 1:38:41 AM
I am using Visual Studio .NET 2003 with SQL Server 2000. I am trying to
insert the date and time into a SQL database by using hour(now). I am having
a hard time trying to figure out which datatype to use in SQL to store this
value. I have tried using datetime, char, nchar, text and nothing see... more >>
need help with query
Posted by TJS at 2/23/2005 1:17:30 AM
I want to sum the records in a table (u) which have 'P.M.' in a field value
and test against a fixed limit
something to the effect of :
case
when SUM(substring(u.sTime,1,4)='P.M.') <= 64 Then ....
except it should work :)
any suggestions would be appreciated
... more >>
DTS Designer Error: The specified module could not be found
Posted by Venkatesan at 2/23/2005 12:34:34 AM
Hi folks
I am connecting to a SQL Server 2000 (SP3) from a client Enterprise
Manager. It connects to it, well.
But if I try to open an existing DTS package (located under Local
packages) it throws an error "DTS Designer Error The specified module
could not be found" and it closes.
Same error... more >>
|