all groups > sql server programming > december 2003 > threads for tuesday december 30
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
Column with runing values
Posted by Naveed Akbar at 12/30/2003 11:46:17 PM
Hi all,
Its great to see that so many ppl helpout each other. I hope I can do the
same on day :), anyway Can any one please guide me that how can i make a
runing column in result set e.g.
i have a query
select au_id,au_lname,au_fname from authors
which returns
au_id a... more >>
Update SET where NULL
Posted by Russ Franklin at 12/30/2003 11:25:10 PM
Hello,
How do I set the column of a table so that where it
equals null it gets populated with a certain value.
What I have tried is:
update HAIRCUT
set HAIRCUTCD = '001'
where HAIRCUTCD = NULL
and
update pipe_pipeNo
set ContractId = '001'
where ContractId = 'NULL'
and
upda... more >>
VarBinary type conversion
Posted by JMcCoy at 12/30/2003 9:51:30 PM
Hello,
I've an issue with converting varBinary data into other data types. The
column definition is varBinary(2498).
How do I pull the data out for a user? Here's what I've tried thus far:
DECLARE @myval decimal (5, 2)
SET @myval = 193.57
Insert INTO Test_Tbl1(varBintst)
... more >>
Bug in sql analyser, execution plan shows always 0
Posted by Stijn Verrept at 12/30/2003 8:50:11 PM
When I look at the execution plan of a query all steps are 0%. Now
when I change my local settings from Dutch to United States it comes up
correctly (same query of course).
See here for Dutch: http://www.entrysoft.com/be.jpg
Here for US: http://www.entrysoft.com/us.jpg
Is this a known bug?... more >>
Allocating an Object to a Filegroup
Posted by GYK at 12/30/2003 8:21:05 PM
Hi,
I know how to allocate a table to a particular user defined filegroups, while creating it.
But how can one allocate other data objects like Stored procedure, functions, views to a particular filegroup
Thanks in Advanc
GYK... more >>
Group sometimes, part II
Posted by Stijn Verrept at 12/30/2003 7:13:38 PM
Sorry for reposting but I have removed all fields and tables that
weren't necessary for this problem so it will be much easier now :)
DLL:
CREATE TABLE [dbo].[CodeLink] (
[CL_ID] [int] IDENTITY (1, 1) NOT NULL ,
[CL_COID] [smallint] NOT NULL ,
[CL_SNID] [int] NOT NULL ,
[CL_Begin] [sm... more >>
search word
Posted by kuya789 NO[at]SPAM yahoo.com at 12/30/2003 5:34:41 PM
search word: ok
if i use
SELECT * FROM sometable WHERE someColumn like %searchword%
it will return results that include these characters
ex: look
I would like to search the word "ok" in the db as a whole word.
YES: dsfd dfdf ok dfdf
NO: dfdsf look dsfsdf... more >>
Concatenate Rows/Columns
Posted by Tom S. at 12/30/2003 5:01:17 PM
Hello,
Table 1:
MainID Qty Message
1 3 "Apple"
2 5 "Orange"
3 5 "Banana"
Table 2:
MainID SubID
1 "A"
1 "B"
1 "B"
1 "C"
2 "F"
2 "F"
2 "H"
3 "A"
3 ... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
INSERT NEW RECORD BETWEEN
Posted by simon at 12/30/2003 4:57:19 PM
I have table with columns of start and end date.
startDate endDate ID
2003-11-24 23:00:00 2003-11-24 23:10:00 1
2003-11-24 23:15:00 2003-11-24 23:20:00 1
2003-11-24 23:25:00 2003-11-24 23:35:00 ... more >>
simple SQL query
Posted by GriffithsJ at 12/30/2003 4:46:58 PM
Hi
I know it's possible to do the following, but not sure of the SQL required.
I've two tables, table A and table B
Table A has amongst others, two columns 'person' and 'address'
Similarly, Table B has amongst others, two columns 'person' and 'address'
What I want to do is to get a sing... more >>
Resetting the auto increment field
Posted by Maziar Aflatoun at 12/30/2003 3:46:26 PM
Hi,
Does anyone know how I can reset an auto-increment field in a table
(Microsoft SQL Server). So that it starts counting from 0... again?
Thank you
Maz.
... more >>
wait command using a cursor
Posted by ed braslis at 12/30/2003 3:10:26 PM
Is there a way within a curor to wait for a command to complete before
fetching the next row?
declare victim_cursor cursor for
select spid
from mast.dbo.sysprocesses
where spid >=@spidlow and spid <= @spidhigh
and db_name(dbid)='OnePoint'
open victim_cursor
fetch next from victim_cursor ... more >>
table variable question
Posted by joe at 12/30/2003 3:08:59 PM
Hi,
I tried to use table variable in sp_executesql statement, it failed. So
I assumed that table variable can't work with sp_executesql because
sp_executesql doesn't treat table variable as "variable" . Can you confirm
this?
thanks
Joe... more >>
SQL Query
Posted by kuya789 NO[at]SPAM yahoo.com at 12/30/2003 2:37:27 PM
My db table looks like this
FILENAME FILE_CREATED FILE_MODIFIED
test 9/12
test2 9/13 10/13
..
..
all FILE_CREATED field have value, only some FILE_MODIFIED have value.
I need to get the value of FILENAME column and this is what i have
SELECT FILENAME FROM REW_FILES ... more >>
Greatest Function
Posted by Jim at 12/30/2003 2:24:35 PM
Is there anything in SQL Server 2000 that allows me to
pull the greater of 2 columns in a query?
Example. I have a row with 3 cols. In col1 is a
generated key. Col2 has a date and Col3 has a date. In
my query I want to return only the generated key and the
column that has the greatest... more >>
LOOP??
Posted by Anita at 12/30/2003 2:03:02 PM
I have a sql server table with a unique id for an
individual and 11 languages, if they speak the language
the value if 1 if they don't it is 0. How do I just query
to get the individual and the first 5 languages they
speak? I do not code well, and this is really baffeling
to me. THANKS!!... more >>
SQL Server not using optimal indexes
Posted by Brandon Lilly at 12/30/2003 2:02:03 PM
I have three different stored procedures that have been performing
very poorly. We finally tracked the problem down to SQL Server
choosing a sub-optimal index in the query plan. For some reason it is
insisting on choosing a clustered index scan instead of utilizing
another index. We are havin... more >>
Forcing auto-update statistics to fire (SQL Server 2000)
Posted by Jerry Brenner at 12/30/2003 1:52:08 PM
Our users have potentially dirty legacy data that they
need to get into our application. We provide a set of
staging tables, which map to our source tables, that the
users do their ETL into. Every row in the source tables
has a generated integer id. Every row in both the source
and stag... more >>
Create an Index on a function
Posted by Hamed at 12/30/2003 1:45:48 PM
Hello
I have a function written in C that gets a string as input and returns
another string that is manipulated by the function according some rules. I
need to make an index on a field in a table in sql server 2000 based on the
output of this function. How can I make it?
I also need to write ... more >>
Query Trigger question
Posted by kb at 12/30/2003 1:31:23 PM
Looks like my last post didn't take. I received the following code from Pat (thank you!)
CREATE TRIGER tiMyTable
ON MyTable
FOR INSERT
AS
UPDATE myTable
SET strata = Rand()
WHERE EXISTS (SELECT *
FROM updated
WHERE updated.SID = myTable.SID)
EXECUTE sp_sendmail ... more >>
NEED HELPS ON A TOUGH QUERY
Posted by joe at 12/30/2003 1:17:36 PM
sp_depends doesn't return objects outside of current db
how do I write a query that returns all objects names inside a procedure?
for example,
sp_find_objects @proc='get_employee_info'
... more >>
Simple but complex report
Posted by AstrA at 12/30/2003 12:53:46 PM
Hi All
Wondered if you could help.
Basically I have 2 tables that contain all the data I want for my report,
but I need to put it in a particular way and I need to display it in an ASP
page so my queries got to be manual rather than an MS Excel/Query 'munge'.
To be honest, the report itse... more >>
Dynamic Query for Searching data
Posted by kk at 12/30/2003 12:42:13 PM
Dynamic Query for Searching data
I have a stored procedure which takes three parameters.
The parameters would be null or would have values.
Currently I am doing like the below listed code and it
takes a long time to execute because of the Varchar
conversions. Is there an easier and fast... more >>
Quick Q on EXEC and SET
Posted by Mij at 12/30/2003 12:21:03 PM
Hello all,
Does anyone know why I can't do this:?
declare @numspec int
EXEC("
SET @numspec = 3 ")
I tried a multiline Exec with concatenated strings, but even
this simple one doesn't work.
??
Thanks.
Mia J.
*** Sent via Developersdex http://www.developersdex.com ***
Don't ju... more >>
Saving a Strings Font attributes
Posted by Deke at 12/30/2003 11:57:09 AM
Hi,
Is it possible to save how a string looks? Say I string
with the font strikethrough on can I save the string like
that?
Deke... more >>
Group, but only sometimes
Posted by Stijn Verrept at 12/30/2003 11:54:36 AM
This msg didn't appear first time for some reason (thanks Steve for
letting me know :)
I have a Codes table and a CodeLink table. I need a query that returns
all the rows from the CodeLink. But I need them grouped by Code if the
field CO_Group = 1 (CO_Group is a bit field of codes table).
... more >>
SQL Case Statement
Posted by Allen Heim at 12/30/2003 11:49:56 AM
I am trying to use a SQL case statement inside another SQL=20
statement to calculate different values depending on the=20
value of another field. For example:
SQLString =3D "SELECT bom_detail.id_seq as 'Item #', " _
& "Part as 'SSF_Part_#', Assembly as 'Subassembly_#', " _
& "lv as 'Level', ... more >>
Bug in bcp
Posted by Al-Ameen at 12/30/2003 11:46:28 AM
I'm using bcp utility on SQL2000-SP3, from inside a stored-in procedure using this working syntax:
exec master..xp_cmdShell 'bcp myDB.dbo.myTbl out \\eyad\rpl_root\myTbl.dat -Smysrv -Uuser -Ppas -CRAW -c'
everything is ok for that.
but when inputting:
exec master..xp_cmdShell 'bcp m... more >>
Stored Procedure
Posted by Vitamin at 12/30/2003 11:28:44 AM
I have two database
dbA: dbA
dbB: dbB
dbA contain 2 tables:
tbl_01A
tbl_02A
dbB contain 2 tables also:
tbl_01B
tbl_02B
how to if I want to get the value from tbl_01A, and the recordset of tbl_01A
would used for tbl_01B, in stored procedure.
thx~~
... more >>
Opening a cursor on with Dynamic SQL statement
Posted by Christopher Pragash at 12/30/2003 11:08:19 AM
Hello All,
I'm facing the following two issues in a stored procedure:
1) I'm trying to open a cursor on a dynamic SQL Statement. Can this be done
and if so what syntax would I use?
2) As an alternative to the above issue I tried to Insert the values of the
dyamic SQL statement using the '... more >>
Newbie question on triggers
Posted by kb at 12/30/2003 10:41:10 AM
I have two fields in a table: SID and Strata. What I would like to do is when a new SID is inserted into the table, have a value assigned to Strata based on the Rand() function for only that SID. (one of two values at 50% each)
Then I'd like to use xp_sendmail to send the SID and Strata values ... more >>
DB restore error
Posted by GriffithsJ at 12/30/2003 10:03:19 AM
Hi
I'm passing the following SQL statement to my SQLServer:
RESTORE DATABASE myDB FROM DISK 'd:\mssql\backup2\myDB.bak' WITH MOVE 'myDB'
TO 'd:\mssql\data\myDB.mdf', MOVE 'myDB_log' TO
'd:\mssql\data\myDB_log.ldf'
However, when I run this, I get the following error:
Server: Msg 3234, ... more >>
Code Works in iSQL but not SP. Why?
Posted by BenignVanilla at 12/30/2003 9:55:33 AM
I am trying to write a SP that essentially calls another SP twice with
different arguments and then returns the two recordsets as one. Here is the
code as it runs in iSQL for testing. This works, returning 54 rows.
DECLARE @OfficeCD VARCHAR(10)
DECLARE @FiscalYr VARCHAR(4)
DECLARE @iAppUs... more >>
Regex's in sql
Posted by Otis B. Driftwood at 12/30/2003 9:51:41 AM
"Jacco Schalkwijk" <NOSPAMjaccos@eurostop.co.uk> wrote in message
news:#dOUcUvxDHA.3416@tk2msftngp13.phx.gbl...
> Regex will be supported Yukon via the CLR languages. Can you provide me
> with a scenario where you have used regex in SQL. It would be interesting
to
> see what you can do with it.... more >>
Updates and non-clustered indexes
Posted by Hutch at 12/30/2003 9:01:17 AM
I have a question in regards to updates and non-clustered indexes
I have a table with 500,000 rows with a clustered 5 column PK and a one column non-clustered index. I added a new Money column to the table and updated it with a 0 and noticed to take a very long time.
My question is why would an u... more >>
compute
Posted by Binny at 12/30/2003 8:01:03 AM
Is there a way to direct the output of following query to
a table/tables?
select col1,col2,state,amt from t1
order by state
compute sum(amt) by state
compute count(col1)
Can i achieve the same output by using rollup/cube
grouping clauses.?
... more >>
Need your help
Posted by NiitMalad at 12/30/2003 6:37:55 AM
Dear Friends
I am having a table where i have three columns
1. Category
2. Invoice Number
3. Amount
The category can be ABC , XYZ , PQR
The invoice is 100 200
I want to use the Case function so that there will be
columns with Invoice number say 100 and 200 which will
show the amou... more >>
SP Help Please!!
Posted by J Jones at 12/30/2003 5:43:58 AM
I have 10 values I want to pass as parameters into a stored procedure and
have those param values evaluated against the conditions that are stored in
a SQL table and return the NOTE field of those rows where the condition is
true.
The conditions are just strings that I want to use to compare th... more >>
alter PK add col.
Posted by Shonet at 12/30/2003 4:23:36 AM
Hi!!
I need to alter a primary key to accommodate one more col.
ex:
FK PK MANU
PK HEAT
PK GRADE
PK PROJ <- new column
How do I create a script to do this and populate the new
column so that where the MANU column has a value of '4'
insert into the new PROJ column the valu... more >>
Why does MS SQL Server 2000 use "\" in its naming
Posted by Summit at 12/30/2003 2:05:59 AM
i.e.
mymachinename\mysql2000... more >>
|