all groups > sql server programming > march 2005 > threads for tuesday march 1
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
MAX
Posted by Frank Dulk at 3/1/2005 10:49:45 PM
I have the following code that I created today:
select month(DataPesquisa) as Mes, count(FConceito) as Bom,
isnull(Excelente.Conceito,0) as Excelente,isnull(Regular.Conceito,0) as
Regular,
isnull(Ruim.Conceito,0) as Ruim
from satisfacao x
left outer join (select referencia, count(Fconceito) ... more >>
Strange problem with stored procedure parameter
Posted by gemel at 3/1/2005 10:10:06 PM
I have a simple stored procedure that is defined as shown below:
CREATE PROCEDURE get_books_by_title
@title char(60)
AS
SELECT * FROM Books
WHERE Title LIKE @title
GO
I call this procedure witha wildcard as shown:
exec dbo.get_books_by_title '%'
but this only returns 4 out of the 1... more >>
help with a SELECT
Posted by J.C. Developer at 3/1/2005 8:35:44 PM
Hi, I have a table that contains orders from cliente. Suppose that each
client has more than one order, I would like to write a SELECT statement
that returns the order with the oldest date from each client.
for example:
Table:
idClient idOrder orderDate
35 100 ... more >>
Newbie Date Question
Posted by Colin H at 3/1/2005 8:11:35 PM
Hi all,
I need a 'select' query that can give me the date of the first 'Monday' in a
month for any given month, but am not sure how to go about this.
Say I want to know the date of the first Monday in June ?
regards,
Colin H.
... more >>
Trigger on UPDATE
Posted by Just D. at 3/1/2005 8:05:56 PM
All,
How should I write the trigger on update? I'm sure the question is too
simple.
If I update only one record or a group of records I need to update the
LastUpdate (datetime) field in all these updated records. How can I select
only updated records in this trigger?
Just D.
... more >>
String Manipulation
Posted by doc at 3/1/2005 6:51:11 PM
I have a field within a table called customer with a field called address.
tbl.customer.address
10 acacier avenue
11 acacier avenue
1056 acacier avenue
Etc Etc
I need some help to figure out how to separate the string at the first
space so I may move the house number to a new field.
A... more >>
Canceling CHeckIdent Message
Posted by Roy Goldhammer at 3/1/2005 6:50:10 PM
Hello there
I have srore procedure that do some changes on the database
In order to make sure that all the changes will be together i using
transation with SET XACT Abort
It works fine on any errors and warnings, even on warnings that don't need
to stop the process. In the code i also res... more >>
Replace Function
Posted by pramod NO[at]SPAM luxoroffice.com at 3/1/2005 6:33:38 PM
Dear All,
In my Item Master table, the item column has values like 'printing' in more
than 1000 rows. This was a data entry error. Now my user want all the
instances of 'printing' to be replace by 'printed'. Is there any ways to
update the entire rows in one go, or I will have to change the na... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
temporary table in a batch
Posted by Emre Guldogan at 3/1/2005 6:06:45 PM
Hi,
I have such a batch:
/* some statements */
update T1 set F1 = some_expression where T1.ID in (A_BIG_QUERY)
/* some statements */
I use this A_BIG_QUERY source about 3-4 times in this batch for different
purposes
and this A_BIG_QUERY requires a dynamic parameter to produce a result s... more >>
Re-Post Sum of Sum from 2 tables
Posted by ericvdb at 3/1/2005 6:01:55 PM
Thanks, it worked.
Is there a way to add another column to the query that shows the total of 1
column:
pieces volume Pieces Free Volume Free Invoiced TotInvoiced
1 1 0 0 10
50
1 2 0 ... more >>
RE: Sum of Sum from 2 tables
Posted by ericvdb at 3/1/2005 5:48:21 PM
Thanks, it worked.
Is there a way to add another column to the query that shows the total of 1
column:
pieces volume Pieces Free Volume Free Invoiced TotInvoiced
1 1 0 0 10
50
1 2 0 ... more >>
dynamic column name?
Posted by Max at 3/1/2005 5:38:32 PM
I want to create a table where the column names and number of columns is not
known. It can be a temp table or table variable.
Something like:
DECLARE @output table (@columnname int)
or
ALTER TABLE @output ADD @columnname varchar(50)
-Max
... more >>
SQL2000server database path change
Posted by S Kaliyan at 3/1/2005 5:33:25 PM
hi pauls
i am using ms-sql2000server on win2k server, i have three partition C,D $ E
, C is NTFS format other two FAT32. my DB laying in C drive now i need to
chage to D drive how can do it.
Please suggest me suitable solution.
Regards
S Kaliyan
... more >>
"Prepare" in SQL Server through ODBC/ADO
Posted by craigkenisston NO[at]SPAM hotmail.com at 3/1/2005 5:28:57 PM
Hi,
When using an interface like ADO or ODBC, there is a call named
"Prepare" which supposedly sent the statement to the server which in
turn should parse it, save the query plan and return a handle to the
client so subquent calls just refer to this handle/id and get faster
execution in batch... more >>
How to count the columns of a table
Posted by Sascha A. Koenig at 3/1/2005 5:24:52 PM
Is there an easy way to count the columns of a table in T-SQL?
Thanks for your help
Sascha
... more >>
Date w/hrs and min
Posted by David C at 3/1/2005 5:09:03 PM
I have a datetime field that I want to display as m/d/yyyy hh:mm AM
I tried the convert below but it did not return what I want. Thanks.
CONVERT (smalldatetime, dbo.ActivityHistory.ActivityDate, 201)
David
... more >>
Using CONTAINS with sp_executesql
Posted by Mark Holahan at 3/1/2005 4:44:44 PM
Hi,
Has anyone ever used the "CONTAINS" predicate when writing a dynamic SQL
statement using sp_executesql?
e.g.
DECLARE @sSQL NVARCHAR(1000)
SET @sSQL = N'SELECT Name FROM Employees E WHERE CONTAINS(E.Biography,'
+@BioBlurb)'
I've spent a whole day experimenting, unsuccessfully, tr... more >>
Multi-Database Performance
Posted by Ed at 3/1/2005 4:07:02 PM
Hi,
If i query multi-database and join them together, would there be any
performance issues? Right now we have 3 differenet databases but they are
related to each other. I would like to find out if there are any performance
issues to query across three different databases
Thanks
Ed... more >>
Unique index
Posted by Joaquim Meireles at 3/1/2005 3:55:06 PM
I have a table1(key, field1, field2, field3...).
My primary key is "key".
Then i create a unique index for fields "field1" and "field2".
This works, but i want thar sql server retrieve me the values thar are being
duplicated.
I'm using sql server 7.0.
Can anyone help me???
... more >>
combine data from different records with same ID
Posted by culam at 3/1/2005 3:23:06 PM
I have a table contains comments. User scan create as many comments they want.
my job is to combine and rearrange all comments in order of dates and time.
acct date time Comments
--------- ------- -------- ---------------------------------------------
... more >>
How do i backup the logShipped Database, that is still in stand by mode?
Posted by Nik at 3/1/2005 2:35:23 PM
Gurus
Is there a way to backup the standby database. I am logshipping from
Location A to Location B Sever X,
On Location B I have Server X as well as Server Y ,
But I need X to be stand by mode and Y to Be used for reporting mode.
my idea was to backup Server X and Load that backup on Server Y... more >>
different behaviour of SQL Server 2000 errors dependent on windows OS
Posted by Ollie Riches at 3/1/2005 2:32:29 PM
I am having a problem inserting data into a database table. There is a
stored procedure that is attempting to insert data into several tables, if
there is a duplicate entry already exists in the table then a unique key
violation is thrown back from sql server (2000) to the data access layer.
The... more >>
Get a list of the objects owned by a users
Posted by Chris V. at 3/1/2005 2:24:37 PM
Hi,
My question may be stupid, but can;t figure out a way to do it "simply".
I'm taking over the admin of some SQL instance and I want to clenu up the
logins list. But before deleting anything, I need to know what objects are
owned by the user I want to delete to not brak anything.
Is the... more >>
Union All - Help
Posted by Philip Dodgson at 3/1/2005 1:45:32 PM
Hi All,
I am trying to get some help of re-writting a piece of code as shown
below
SELECT
code,
description,
clientDescription,
band,
AVG(rental) AS value,
COUNT(tableTemp.surveyID) AS [count],
CASE clientID
WHEN @clientID THEN 1
ELSE 0
... more >>
SQL Query Help: catching a missing number
Posted by Onnuri at 3/1/2005 1:40:37 PM
Hi,
Would show me an SQL query to capture missing numbers from the consecutive
order of numbers? For example, number 5 and 7 are missing from 1 to 10, how
can I capture them?
Please let me know.
Onnuri
... more >>
Weeknumber problem
Posted by M. de Jong at 3/1/2005 1:23:26 PM
People,
Does someone has a function that calculates the correct weeknumber. My
systems says that 01-01-2005 has weeknumber 1 instead of 53 and monday
03-01-2005 is weeknumber 2 instead of 1.
Thanks in advance.
Martijn de Jong
... more >>
nt user name
Posted by Ed at 3/1/2005 1:19:04 PM
hi,
How am I able to get NT User Login Name?
I Don't mean suser_sname()...
because we have an application that always uses ReportUser to login to the
database to retrieve data, but somehow we still want to caputure the NT Login
Name since suser_sname() always return ReportUsuer...
Than... more >>
cross tab question
Posted by Kurt Schroeder at 3/1/2005 1:17:04 PM
I am trying to create a cross tab query to to combine the rows for two dates
on one line:
DATA:
( query to get this data:
select top 6
stkhstCsiSym,
stkhstDATE,
stkhstXO
from stkhst
where stkhstdate >=20050225
order by stkhstcsisym, stkhstDATE)
1006 20050225 O
1006 20050228 X
... more >>
Selecting record with specific datetime
Posted by Keetra44 at 3/1/2005 1:05:10 PM
I have a table with a field of type datetime whose default value is
getdate(). So, when a user entered a new record at
'5/21/2004 11:10:10 AM', that value was automatically entered in that
column.
Now I'm trying to write a select query that will retrieve that particular
record based on... more >>
array?
Posted by Jason at 3/1/2005 1:04:57 PM
Hello,
I was wondering if there is an alternative for an array in sql server.
What i would like (correct me if i approach this the wrong way) is an array
which i can use in a where clause based on a variable/parameter.
for example:
using a select statement to retrieve a list of titles or... more >>
Update and CASE question
Posted by Adrian at 3/1/2005 12:46:11 PM
Using SQL Server 2000 and the following tables and values.
================================================
CREATE TABLE [Table1] (
[ID] [int] NOT NULL ,
[TelephoneNo] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
(
[ID]
) ON... more >>
Question
Posted by Leonid Brehznev at 3/1/2005 12:44:55 PM
Does this statement applied to SQL2K as well ?
Thanks.
....when you use the INSERT...EXEC statement to load a
temporary table, as the stored procedure itself creates
temporary tables, and you end up with blocking locks in
tempdb similar to those described above. The prescribed
workarou... more >>
value pair database design I need help with
Posted by Max at 3/1/2005 12:14:18 PM
I have 3 tables that store all the data for my application. I wanted the
database structure to allow the user to define the "columns" rather than
hardcode them in the database design. This allows the user to define menus,
categories, and fields for this "content manager" type app.
The major... more >>
Simple Query
Posted by Aneesh R at 3/1/2005 11:56:31 AM
Hi,
I have a table having the values
ID Nam age
1 aaa 17
2 abc 18
3 acb 19
4 bbb 15
5 bbc 20
6 ccc 28
I want to list all the top entries having the highest age
Like
3 acb 19
5 bbc 20
6 ... more >>
Expanding sp_executesql Parameters?
Posted by Mark Holahan at 3/1/2005 11:47:00 AM
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with =
the parameters expanded?
I'm losing years of life trying to get the following dynamic SQL =
statement to work:
DECLARE @sSQL NVARCHAR(1000)
DECLARE @PropStreet1 VARCHAR(50)
SET @PropStreet1 =3D '... more >>
rename a database
Posted by Malin Davidsson at 3/1/2005 11:38:49 AM
Hi,
How do I rename a database without changing the users permissions?
I have tried
ALTER DATABASE old_db_name
MODIFY NAME = new_db_name
and
EXEC sp_renamedb 'old_db_name','new_db_name'
and both give me:
Server: Msg 5030, Level 16, State 2, Line 1
The database could not be exclu... more >>
Retreiving in Random Order
Posted by Steven Richardson at 3/1/2005 11:18:07 AM
Help please!
How do you retreive a query & sort the results in a random order?
Many Thanks
Steve
... more >>
Help with One-to-Many query
Posted by larzeb at 3/1/2005 11:08:58 AM
Given the following two tables:
Parent Child
---------- ---------
ParentID ParentID
ChildID
how can I retrieve the Child row which has the highest value of
ChildID within any single Parent row?
The following does not work.
SELECT * FROM Parent p
I... more >>
SQL Collation Error
Posted by Rick at 3/1/2005 10:33:05 AM
I get the following error when I run a script in our server that we use to
review code. I am now getting the same error with different querries on
different databases on the same server. Both servers are running SQL 2000. We
just recently upgraded our OS to Win 2003, and reinstalled SQL 2000. ... more >>
How to copy a table containing a few million rows effciently?
Posted by Karan at 3/1/2005 10:33:03 AM
I have a table in SQL Server 2000 which contains about 5 millions rows and
keeps growing at the rate of 500,000 rows per month. This is a live
production table into which data is inserted/updated contantly. This table
contains a few indexes and keys. The activity on this table is extremely hig... more >>
Invalid Column?
Posted by Dave S. at 3/1/2005 10:12:17 AM
Two things I could use help with. First one is I know there is probbaly a
way better method to do this and I would love someone to show me what it is
having just begun in the SQL trans language. The 2nd is, I am curious why,
even though its clearly not the best method, why it doesn't work and ret... more >>
SQL Server 7 Permissions!
Posted by b NO[at]SPAM man.com at 3/1/2005 9:37:00 AM
Hi,
I have SQL Server 7 (SP6) installed on an NT4 (SP6a) and I have a
problem with permissions - I set permissions on tables for a user (that
is an NT User itself) - both using the enterprise manager and using SQL.
Problem is that it doesn't matter - I can still perform
INSERT/UPDATE/DELETE... more >>
getting tables size
Posted by z. f. at 3/1/2005 9:24:35 AM
Hi,=20
is there a method of getting table current size?
TIA!!... more >>
Getting back random number assigned in trigger
Posted by David C at 3/1/2005 9:14:19 AM
I have a table that has a unique ID assigned by a random number in an INSERT
trigger. This trigger was created from an Access upload of a table with a
random autonumber (replicated table). I am using the code below to add a
new record to the table but it does not return the new ID. Besides ... more >>
Re-Post
Posted by Phil at 3/1/2005 8:49:04 AM
Hi all,
I asked a question earlier about speeding up a union all statment like below
SELECT
code,
description,
clientDescription,
band,
AVG(rental) AS value,
COUNT(tableTemp.surveyID) AS [count],
CASE clientID
WHEN @clientID THEN 1
ELSE 0
... more >>
Image Data
Posted by John316 at 3/1/2005 8:41:30 AM
What is the correct (or best way) to
Insert Into an Image data field.
I have an app that displays records containing Equipment Pictures.
I am able to display the record and display the picture.
I want to allow the user to add an new record and also insert a
new picture associated with the r... more >>
UDF changing data type from varchar to date by itself!
Posted by RogerKirkham NO[at]SPAM yahoo.co.uk at 3/1/2005 8:31:26 AM
I have created the following UDF:
CREATE FUNCTION dbo.udf_ConvertBC (@ValToConvert varchar(255))
RETURNS varchar(255) AS
BEGIN
DECLARE @Object int,
@return varchar(255),
@MethodToCall varchar(255)
SET @MethodToCall = 'c128setbhumanreadable(' + @ValToConvert + ')'
EXEC sp_OA... more >>
Convert image to hexadecimal
Posted by Jacques Roumimper at 3/1/2005 7:34:43 AM
I want to export data from my tables by generating insert statements,
including data of type image. To avoid having to use textcopy.exe or
textptr, I want to have the image data part of the insert-statements by
converting the binary image data to hexadecimal strings. Also, the
image data is larg... more >>
Writing ONE STORED PROCEDURE rather than 5
Posted by pmud at 3/1/2005 7:31:08 AM
Hi,
I have created the following 5 stored procedures which return rows based on
the user input...
Now what i need to know is that is there a way of ....rather than writing 5
stored procedures....I can merge all these into a single stored procedure....
so that when the user doesnt enter a... more >>
how to get char length on text column?
Posted by Chris at 3/1/2005 7:01:06 AM
How would I get the number of characters on a text column?
select len(mytextcol) from mytable -- fails
tia,
chris... more >>
Global Temporary Tables
Posted by Forch at 3/1/2005 6:29:08 AM
Hi guys...
This SP works:
/*******************************************************/
Create Procedure tmpMF1
as
Create Table ##fun (line varchar(1000));
insert into ##fun (line) values ('Hello');
exec Master..xp_cmdshell 'bcp "select line from ##fun" queryout
"c:\fun.txt" -c -S"... more >>
How do I run a DTS package from Visual basic 6?
Posted by Dawn at 3/1/2005 5:51:03 AM
Can anyone help me. I have a basic DTS package exporting data and all I want
to do it click on a button in Vb and trigger this package to run.
Should I be looking at the command object, or am I way off track here?
I'd really appreciate any help anyone can give me.
Thanks
Dawn... more >>
XP_sendmail Issue
Posted by Kyle at 3/1/2005 5:27:04 AM
I am trying to use XP_sendmail and get the following error:
ODBC error 7410 (42000) Remote access not allowed for Windows NT user
activated by SETUSER.
Can anyone help ?
Thanks in advance,
Kyle... more >>
Perfomance
Posted by Phil at 3/1/2005 4:33:02 AM
Hi All,
I have a little bit of code that looks something like this
SELECT
code,
[description],
clientDescription,
band,
AVG(rental) AS value,
COUNT(tableTemp.surveyID) AS [count],
CASE clientID
WHEN @clientID THEN 1
ELSE 0
END AS color
... more >>
|