all groups > sql server programming > august 2006 > threads for thursday august 17
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
Function for finding the median in T-SQL?
Posted by JP at 8/17/2006 9:40:34 PM
I have a sql statement that returns the last four quarters of sales
numbers for a given salesperson. What I would like to do is exclude the
highest figure and the lowest figure then sum the two middle figures and
divide by two.
I was thinking a median function would help but couldn't find a... more >>
SQL Server - Function Table Call
Posted by Amb at 8/17/2006 6:55:01 PM
I have a request from a friend that I personally don't think is possible
without a cursor loop:
Lets say I have a function that returns a table: Similar to below - and it
will only ever, no matter what, return one row.
create function dbo.fn_henfruit(@a int, @b int) returns table
as
... more >>
Select against calendar table
Posted by Terri at 8/17/2006 5:47:37 PM
I'm looking to set the variable @BusinessDayFactor based on a select against
a calendar table. The select will have one parameter @ReportDate. The logic
is as follows:
Given @ReportDate count the subsequent, contiguous days which are not
business days if those non-business days are in the same... more >>
Run a .vbs job
Posted by Scott at 8/17/2006 5:26:40 PM
Is it possible to create a job that fires a .vbs script file?
... more >>
PLEASE HELP with Query
Posted by Michael Kintner at 8/17/2006 3:43:33 PM
I am trying to use a IN statement
Select * From ShowMenusFirst WHERE (Security In ((select Security from Users
Where (Username='mkintner')))) ORDER BY Menus.Level;
The results from the query select Security from Users Where
(Username='mkintner') is 'Low','Med'
I wanted the IN Statement ... more >>
how to better manage jobs created by reporting services?
Posted by === Steve L === at 8/17/2006 3:23:00 PM
the job names and step names are so encripted, they often look like
4DC18F43-DF2F-4F12-BAFB-58DD054EF0BA
or
exec ReportServer.dbo.AddEvent @EventType='TimedSubscription',
@EventData='4ade808a-0199-4
is there an easy way to find out a report name the job is referring
from sql side?
thank ... more >>
insert into table
Posted by Zeng at 8/17/2006 3:13:46 PM
Hi,
I thought we can just do this insert...into statement to copy data from one
table in another db but it gives me errors below. Both product tables have
the same schema.
insert into db1.dbo.product
( select * from db2.dbo.product )
Server: Msg 156, Level 15, State 1, Line 4
Incor... more >>
Scramble Integer column?
Posted by nkw at 8/17/2006 2:29:01 PM
I have an int column for client ID (with unique contraint). Is there a good
way to scramble the column? bitwise exclusive OR will keep the "neighbor" IDs
still stay together.... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Parse Text Problem
Posted by kaplan.jason NO[at]SPAM gmail.com at 8/17/2006 2:05:04 PM
Hi,
I'm at a standstill on this and hoping that someone can assist. I've
looked at substring, trim, right, and left to no avail.
I have a field called Jobname this field can contain different lengths
of text. Here are some examples
3777914:lsfadmin:IVUSCOUPMANPROD:ivbld:U.D67829MVUSP002... more >>
Run a query against multiple databases
Posted by Skeptical at 8/17/2006 2:03:32 PM
Hello,
I had asked this question before but I guess my description was not
very clear.
I am able to select all databases from master..sysdatabases, but I am
not sure how to run queries against each so I have something like:
Database Result
database1 1
database2 2
In one table.
I c... more >>
Record count after Insert
Posted by gv at 8/17/2006 2:02:42 PM
Hi all,
I have added 70 records from another table into a table.
When Selecting the count from Query Analyzer I get
the correct new count. When right clicking on properties of the table
I get the old count.
Can someone explain this why?
thanks
gv
... more >>
Bin Location SQL Server 2005
Posted by dkisting at 8/17/2006 2:00:53 PM
Hello,
I have a script which copies the xp_smtp dll to the bin folder of sql. In
SQL 2000, I use the procedure or statement EXECUTE sp_MSget_setup_paths
@SQLPath OUT to get the location (c:\program files...) to the bin folder.
However, this doesn't appear to work in SQL 2005. Is there an equ... more >>
Procedure expects parameter which was not supplied
Posted by ST at 8/17/2006 1:58:02 PM
Hi, I'm getting the error: "Procedure 'PAFF_Activity_Calcs' expects parameter
'@SubjectID', which was not supplied." In my stored procedure. I'm new to
SQL and SQL syntax, so I was hoping someone could look at my procedure and
walk me thru why it's wrong? This is it below:
CREATE PROC... more >>
Help with reconciling data in two tables
Posted by Timothy.Rybak NO[at]SPAM gmail.com at 8/17/2006 12:45:42 PM
I have two tables - PartsShipped and PartsConsumed. Each table has
three columns - Processdate (a date/time stamp), PartNumber, and
SerialNumber.
I need a simple query that will show me the 3 bits of info for all
serial numbers that exist in the PartsShipped table, but not in the
PartsConsum... more >>
Controlling test input
Posted by Jim Abel at 8/17/2006 12:36:49 PM
I am trying to control the format of the text values into a 2000 sql server
single column of a table. The coloumn is a varcchar(50) and the incoming
values typically are as follows,
“New Serverâ€
“new serverâ€
“Standardâ€
“standartâ€
“STANDARDâ€
What I need is the first c... more >>
Tracking Databases On a Server/Instance
Posted by JasonDWilson at 8/17/2006 12:36:36 PM
I am a DBA and have a development DB server (SQL Server 2005) where
developers can send me a request, and I create them a blank database and
administer it, perform backups etc. The users can add tables, views, data,
etc. I want to automate a tool to track all the databases on the server.
... more >>
Trigger and instr
Posted by Vanessa at 8/17/2006 12:35:58 PM
everyone,
Is there is a INSTR built-in function at triggers? I tried to compare if a
variable contains "FED". I tried
If INSTR (@myvar, 'FED') > 0
but it said 'instr' is not a recognize functions. Please help!... more >>
SQL query to find repeat entries
Posted by Greg Smith at 8/17/2006 12:34:54 PM
Can you run a query that will return only results that have the data in a
target column duplicated in another row?
i.e. Duplicate address data
Original table tblPeople:
RecordID Last_name First_name Address
======== ============== ============= ================... more >>
Problems using LinRegR2
Posted by Ash at 8/17/2006 12:20:09 PM
Hi All,
I'm currently trying to use LinRegSlope as follows:
LinRegR2(lastperiods(60), [Measures].[Growth_Avg], ?????)
I would like to regress the growth_avg measure against the following
series (1,2,3,...,60). So, essentially I'm regressing against a time
series from 1 to 60. I cannot s... more >>
Orphaned Trigger...
Posted by dave.seng NO[at]SPAM gmail.com at 8/17/2006 11:57:26 AM
I have a trigger that was copied over from sql2000 to a sql2005 box
that was on the sysusers table. There were apparently 'problems' with
the trigger, and not sure if it's even possible to actually create a
trigger on the sysusers table anymore. Anyway, I can query the
sysobjects and syscomments... more >>
User-defined Select list
Posted by lord.zoltar NO[at]SPAM gmail.com at 8/17/2006 11:36:08 AM
I have a stored procedure that selects from a table, the details of the
query or table aren't that important (it's quite simple). Right now,
the columns it selects are specified explicitly. I'd like for the user
to be able to specify which columns they want to select (There are 2 or
3 columns th... more >>
trigger problem
Posted by Jesse Aufiero at 8/17/2006 11:34:15 AM
Hello,
I'm trying to create a trigger that involves an ntext column and i'm running
into problems. Upon modification to a row in table A, a trigger should
determine if column A, which is an ntext column, was modified. If so, the
trigger should take the new value for column A and insert it... more >>
Backup Job Fails
Posted by Scott at 8/17/2006 10:55:02 AM
When I create a backup job and schedule it, I get the below error. I can
create the job and run it immediately fine. But if I try to schedule it, I
get this error. This is Win 2003 Standard SP1 and SQL 2000 SP4. I also use
Mixed Mode security model. I'm also creating and running logged in as
... more >>
Dynamic "ORDER BY" based on data in database
Posted by William Sullivan at 8/17/2006 10:43:02 AM
I'm dealing with a legacy system (yecch) that I'm trying to search. The data
I'm searching is a flattened representation of a tree. My problem is that my
search results aren't being displayed in the correct order.
Sorting order is controlled by settings stored in the database in two
diffe... more >>
How can I pivot data on a range of integers? - Brain buster here!
Posted by McDale at 8/17/2006 10:39:02 AM
Hey everyone,
I have a situation where I need to take one record and split it up over a
range of integers that could be different for each record. The result would
be one record for each integer in that range. Here is an example:
The table contains
START_NBR int
END_NBR int
SIZE_OF_RA... more >>
Append to end of text data type field in sql 2000
Posted by TCH at 8/17/2006 9:17:04 AM
The notes field is type text in sql 2000. I need to append a line of text
to it. This truncates at 8000:
update tbl_main set notes = cast(notes as varchar) + ' This line is appended
to the text field.' WHERE rcd_id = '01047'
... more >>
Can I use .NDF file recover my data?
Posted by Mike Torry at 8/17/2006 9:11:02 AM
I want to recover data in a table on SQL 2000 server.
This database has 10 files (.MDF, NDF, and LDF). I know which .NDF file
contains the data of the table. I made detach the database.
Can I use one old backed up .NDF file replace the current .NDF file, and
together with other files to atta... more >>
SUB QUERY SELECT
Posted by robken at 8/17/2006 9:08:49 AM
Hi all,
Just a quick question...can anyone tell me if SQL allows you
SELECT...FROM (sub query) WHERE...etc?
i.e is this query possible without first inserting the sub query data
into a temp table?
SELECT place1, SUM([value]) FROM (
SELECT place1, place2, [value] FROM flow WHERE prodid = 1
... more >>
Copy SQL ResultSet to Variable
Posted by StephenMcC at 8/17/2006 8:54:02 AM
Do we know, is it possible to copy the results passed from a select into a
variable (I think similar in the way one can pass a resultset back from a
UFN), so one doesn't have to keep on querying the table to get the results
when required, this variable used as an expression in a nested select ... more >>
Group By Month
Posted by murzik NO[at]SPAM gmail.com at 8/17/2006 8:47:34 AM
Hello,
I am looking to group my query by month and having some problems.
My Query:
SELECT CONVERT(varchar, DateStamp, 110) AS DateAdded,
COUNT(CONVERT(varchar, DateStamp, 110)) AS [#_of_Articles]
FROM InstantKB_Articles
GROUP BY CONVERT(varchar, DateStamp, 110),
ORDER BY dat... more >>
Urgent: Help on query
Posted by Roshan Jayalath at 8/17/2006 7:46:02 AM
Hi all,
I have a large table from which I need to fetch data according to a given
filter conditions. But I will only need to fetch a set of records (Eg : To
display the first 200 records in the table.). Still I would need the total
no. of records which will satisfy the filter to display a t... more >>
Sub-Query Error
Posted by Kevin at 8/17/2006 7:32:02 AM
I am getting the following sub-query error msg,
Subquery returned more than 1 value. This is not permitted when the subquery
follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I understand why I am getting the msg, just not how to resolve the issue.
The SR_Master_D... more >>
Daylight Time
Posted by The One at 8/17/2006 7:26:28 AM
Hi,
can anyone tell me how I can tell if a machine has applied Daylight Time or
not? I need to find this out in a stored proc in both SQLServer2000 and
2005 using T-SQL.
TIA
John... more >>
Loop through MS SQL data with VBScript
Posted by Alex at 8/17/2006 7:13:27 AM
Hello,
I need to write a script that will loop through data within a MS SQL
database and print to a specific printer. I'm totally green when it
comes to VBScript, so I'm not sure if this is possible and if so, what
commands to research.
Can someone point me in the right direction? Thanks,... more >>
Monday from week and year
Posted by Luigi at 8/17/2006 7:01:34 AM
Hi all,
when I have the script:
declare @week int
declare @year int
set @week = 35
set @year = 2006
how can I obtain the monday of that week?
result: 14/08/2006?
Thanks a lot.
... more >>
Insert String into text file using bcp
Posted by ntuyen01 NO[at]SPAM yahoo.com at 8/17/2006 6:53:50 AM
Hi All,
I have a string 'ABC 12345 678910 XXXX '. I want to insert it into
the test.txt file using bcp command. How do I do that.
Thanks for your help.
... more >>
how to find object modified date
Posted by FARRUKH at 8/17/2006 6:43:02 AM
today when I come to work, I noticed someone had modified and deleted few
columns n a table.
Is there any way I can find out when and who modified and deleted columns?
is there any scripts i can run?
thanks
Farrukh... more >>
Complex SQL Query
Posted by ad at 8/17/2006 6:01:02 AM
Hi,
I have the following data from Excel spreadsheet.
LST125A LST075A LST040A PBL125A
LST125A 60 240 240 360
LST075A 240 60 240 360
LST040A 240 240 60 360
PBL125A 360 360 360 60
I need to extract t... more >>
How to retrieve database user
Posted by Mike at 8/17/2006 5:54:36 AM
Hi guys,
I'm new to SQL programming and I want to know if there's a way to
retrieve user in a database that as space in is name.
I'm able to retrieve user with sp_helpuser but if there's a space in
the name of the database I get and error message.
Is there a way to get thru this ?
... more >>
bulk insert from remote machine fails
Posted by Zekske at 8/17/2006 5:26:02 AM
When I start a bulk insert from a network share locally on the server I have
no problem.
When I start the bulk insert (is inside a stored proc) from a remote
computer I get the following error message:
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "\\otherserver\shar... more >>
XML Datatype
Posted by Ramesh Subramaniyan at 8/17/2006 5:12:01 AM
DECLARE @ReceiptItems XML
SET @ReceiptItems = '
<Root>
<Table>
<PaymentDate>1/1/2000</PaymentDate>
<PaidBy>SRamesh</PaidBy>
</Table>
<Table>
<PaymentDate>1/1/2002</PaymentDate>
<PaidBy>subramaniayn</PaidBy>
... more >>
Randomly Pull out Records
Posted by simonmarkjones NO[at]SPAM gmail.com at 8/17/2006 4:59:19 AM
Hi i want to randomly pull out a load of records. I'm quite a newbie to
SQL and was hoping someone could help. I found some code and have tried
to hack it together for our SQL database.
I want to pull out around 1000 randomly selected records. Can anyone
please help modify my code so that it wor... more >>
OpenXML and XML namespaces on SQL Server 2005
Posted by Matthew Robinson at 8/17/2006 4:13:02 AM
I am trying to extract element values from an xml document but having
problems as the document contain namespaces.
This is my code:
declare
@hDoc int,
@XmlRequest XML
set @XmlRequest =
'<?xml version="1.0" encoding="utf-8"?>
<dt:AddTestRequest
xmlns:dt="urn:org.uk.telcob2b/tML/A... more >>
Index Scan Stats Vs Index Seek Stats
Posted by EL at 8/17/2006 2:09:01 AM
I've written quite a complex query and i've been trying to tune certain parts
of it by adding and dropping indexes. In one part of this query it was
joining to a query (made up of columns from two tables called consumerbase
and consumerextensionbase) and showing the estimated execution plan i... more >>
table design for customer rates.
Posted by zubairpam NO[at]SPAM gmail.com at 8/17/2006 1:52:47 AM
Hi,
I'm developing a courier appln which contains the customer rates
different for each customer.
i need to fetch the customer rates from the db. Each and every customer
have different rates for the different countries, cities. I can't
categarize into group bcos of variation in prices with cu... more >>
Differential back up in a SQL 2000 maintenance plan
Posted by Derekman at 8/17/2006 1:49:01 AM
Am I overlooking something or are only full and log backups available in
maintenance plans?... more >>
Timeout while running stored procedure in VS 2003
Posted by Eric Stott at 8/17/2006 1:13:00 AM
I am getting a time out when I execute a stored procedure, I would like to
know where it is timing out (it normally took < 30 sec to run), but no print
commands work so I am at a loss where the issue is being raised.
Where is that supposed to be that I can find out where the issue is causing
... more >>
CASE
Posted by Yan at 8/17/2006 12:00:00 AM
Hi,
I am not sure how to get this write.
I need to evaluate the @Direction param and if it null then add the
following condition to the SELECT statment: AND T1.[Id] IN (SELECT [Id]
FROM Deals)
-----------
DECLARE @FromDate AS DATETIME, @ToDate AS DATETIME, @Direction bit;
SELECT @FromD... more >>
Adding related rows
Posted by Robert Bravery at 8/17/2006 12:00:00 AM
HI all,
I have an insert trigger that inserts additional rows based on the row that
the user inserts
I also have a bridging table that gives me a m:m relationship with another
table.
After the user insert rows into the policysection_division table, the
trigger then inserts multiple rows(dep... more >>
parse
Posted by Roger at 8/17/2006 12:00:00 AM
Platform: Windows 2003 R2 64 bit 32 GB RAM
Sql Server 2005 Enterprise 64 bit with SP1 and all fixes
applied
Executing Parse in Sql Server 2005 Management Studio I get the following
error:
".Net SqlClient Data Provider: Msg 0, Level 11, State 0, Line 0
A severe error occurred... more >>
Good place to post MDX questions?
Posted by Immy at 8/17/2006 12:00:00 AM
Hi all,
Does anybody know of a better place other than the MS newsgroup
ms.public.sqlserver.olap to post MDX questions?
I have what I would believe in a SQL world, a very simple question but my
MDX sucks!
Or if someone here has a descent knowledge of MDX, could I post my question
here a... more >>
|