all groups > sql server programming > november 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
Remove Duplication
Posted by Shmuel Shulman at 11/30/2005 10:35:33 PM
Hi
Is there a way to remove duplicated records
Also if there is a way what about records that are the same except the key
field, is there a way to remove them?
Thank you in advance,
Shmuel Shulman
SBS Technologies LTD
... more >>
cancel update if no column has changed
Posted by param NO[at]SPAM community.nospam at 11/30/2005 8:44:35 PM
Hi all,
Is there a way to prevent an update from occurring if no columns have
changed? I am looking for a way to do this in my stored proc without having
to manually check each column.
Any ideas?
TIA!
... more >>
Sub Query faster than inner Join?
Posted by Matthew at 11/30/2005 7:29:01 PM
I have two tables:
Orders (8million records)
OrderNbr int,
OrderDate datetime,
ItemID int,
......
There's clustered index on OrderNber.
DeleteOrders (1000 records)
OrderNbr int
There's no index on DeleteOrders table.
When I use the below sub query,
delete from Orders where OrderNbr... more >>
server side cursor created by jdbc
Posted by mj at 11/30/2005 7:24:02 PM
I need help for a server side cursor created from java app using MS jdbc
driver.
If I run the statement which is issued by the app replacing the bind
variables, I have the result in 2-3 milliseconds. It shows me index seek on
the appropriate indexes. If I run the same statement the way I see ... more >>
Can not update remote table???
Posted by ronnie at 11/30/2005 7:17:01 PM
Hi,
I have the following update statement but using a linked server
Update txq005dev1.sprint.dbo.becinfo set unit = a.unit from becinfo a inner
join txq005dev1.sprint.dbo.becinfo b on a.HRGType = b.HRGType and
a.ChargSubType = b.ChargSubType
I am not sure why it doesn't work. Can I no... more >>
Using SQL Server 2005 - SQL Native Client as DSN throws up error while inserting values into temporary tables in the application
Posted by John Maly at 11/30/2005 7:00:18 PM
Hi All,
We have a web application accessing a SQL Server database, and it works
fine.
We installed the RTM version of SQL Server 2005, and it works fine if we use
"SQL Server" as the "system DSN" for accessing the Datasource (ODBC)
When we use "SQL Native Client" as the "system DSN", then we ... more >>
Scheduling A Stored Procedure?
Posted by Joe Delphi at 11/30/2005 6:53:54 PM
Hi,
We are using SQL Server 2000. Is it possible to somehow schedule a stored
procedure to run at a specified date and time? I know that its possible
with DTS packages, but this is just a stored proc that performs a
calculation. We want it to run at a certain time every day.
JD
... more >>
custom functions and query optimization
Posted by astro at 11/30/2005 5:59:41 PM
I am building some functions and have not found documentation telling me
if/how that are optimized. For example:
SELECT
companyName,
dbo.getAddress(companyID),
dbo.getContact(companyID)
FROM company
Will the query optimizer build a plan rolling the function SQL statements
into the... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Like operator on subquery
Posted by Jesper Nielsen at 11/30/2005 5:31:01 PM
Hi....
I could use some help here.
Probably newbie question, but i couldnt find any easy solution :-)
I have two tables. Table 1: Calls containing among else A-Number, B-Number.
Table 2: ANumbers containing among else ANumber, Customer number.
In order to select calls going from one cu... more >>
Programatically running the SQL Server Agent
Posted by RSH at 11/30/2005 4:43:13 PM
I have a scenerio where I am using a Push Merge Subscription set with "Run
On Demand". How can I programatically (Stored procedure) run the SQL Agent
Job that synchronizes the Subscriptions?
Thanks,
RSH
... more >>
xml update syntax
Posted by JFB at 11/30/2005 4:29:45 PM
Hi All,
I got this one from lara.
hi,
>>> declare @xmlDoc nvarchar(4000)
>>> declare @hDoc int
>>>
>>> set @xmlDoc = '<FieldTitle1>
>>> <Request>
>>> <Reference>
>>> <Customer>ABC</Customer>
>>> <XpciVersion>1.0001</XpciVersion>
>>> </Reference>
>>> <... more >>
Creating a User Defined Aggregate Function
Posted by Charles at 11/30/2005 4:26:02 PM
Does SQL Server allow the user to create user defined aggregate functions?
If so:
What doed the syntax look like?
Where can I find more information on creating user defined aggregate
functions?
... more >>
Joining tables
Posted by Keith Rudd at 11/30/2005 3:48:24 PM
Can someone please advise how i join the following two tables:
I want to left join on dt,Category and subcategory from Table 1
Table 1:
SELECT TOP 100 PERCENT Y, M, Category, SubCategory,dt
FROM (SELECT dbo.tblCalendar_jp.dt, dbo.tblCalendar_jp.Y,
dbo.tblCalendar_jp.M, dbo.... more >>
Replacing Nulls
Posted by Amon Borland at 11/30/2005 3:33:30 PM
I have a query that has serveral Left Joins. Obviously when there are no
results in the right tables a value of NULL is returned. When creating an
MS Reporting Services report, the tables seem to ignore the NULL values
(because they aren't recognized as real values I assume). How do I alter... more >>
how to store a record before deleting it using triggers
Posted by sabih rehman at 11/30/2005 3:26:01 PM
hey ,
im new to SQL. i wanted to save a particular record before deleting i
using a delete trigger can anyone help me on this .. thn
-
sabih rehma
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
--------------------------------... more >>
Privilege issue on SQL Server 2005 Temporary Tables
Posted by John Maly at 11/30/2005 3:09:16 PM
Hi All,
We have a Web application with SQL Server 2000.
We upgraded to SQL Server 2005. It works fine as long as we use the SQL
Server Driver for ODBC connection. Once we use the new "SQL Native Client "
as the ODBC driver, then, we get an error as follows
ADO error in [CReport::UnitSelecti... more >>
Whats the wrong with this Query?
Posted by vsr at 11/30/2005 3:07:02 PM
SELECT TOP 99 * FROM #TempExt
WHERE eFolderID NOT IN
(SELECT TOP 3564 eFolderID FROM #TempExt ORDER BY service_requested ASC
,sContractName ASC) ORDER BY service_requested ASC ,sContractName ASC
Its not ORDER BY as intended , the out put i am looking is ....first the
result should be ord... more >>
Fast insert
Posted by Ken Abe at 11/30/2005 2:58:02 PM
I need to do insert a lot of data into a table and need to improve
performance. I don't think DTS is adequate since I'm not simply
copying/transforming existing data but rather computing it as I go. I think
transaction logging is an extra cost that I should avoid, but I'm already
using simpl... more >>
Combining Columns of Same Name
Posted by jasdeep jaitla at 11/30/2005 2:50:20 PM
I have 4 tables all with an accountingDate [DateTime] and an amount
[money]. I also have an AccountRegister that acts as a Ledger and has
the invoice items.
I am trying to create a query with a single amount column as a result,
right now my joins create 4 "Amount" columns, is there a way to co... more >>
temp table cannot be found
Posted by Lawrence at 11/30/2005 2:49:02 PM
SQL Question -
declare @sql varchar(1000)
set @sql=select count(*) INTO #tmpReport from TableA
exec (@sql)
select * from #tmpReport
go
How come exec(@sql) indicates that 1 row inserted, but I get "Invalid object
name #tmpReport" from the last select statement.
Any help is appreciated... more >>
Sql server 2000 - copying a diagram - How
Posted by Bob at 11/30/2005 2:09:03 PM
Have used the EM to copy all objects in an existing database on computer a
to computer B, but the diagram did not follow/ How do I copy the diagram(s)
from computer A to B?
Thanks,
Bob
... more >>
Script that Return the number of Rows for each Table on a DB
Posted by imagabo at 11/30/2005 2:06:27 PM
I Have 2 separate data bases with the same Tables and records, I create
a batch to synchronize my data every 2 hours but now I need a Script
that Return the number of Rows for each Table on each DB.
Can someone give me an Idea or the solution for this, I will really
appreciate it.
... more >>
Return value from SP without declaring a variable
Posted by Ben at 11/30/2005 1:49:04 PM
Hi
We are using a 3rd party app that allows us to call functions and SP's.
The only problem is that we can only call one line of a statement:
Where we would usually use:
Declare @Variable VARCHAR(55)
EXEC @Variable = sp_mySP 'testing', ''
SELECT @Variable
We have to call it on one l... more >>
subquery returning more than 1 value
Posted by ChrisR at 11/30/2005 12:50:13 PM
I need to be able to use a View that returns records of data accross, not
down. In other words, I have a table with data:
CREATE TABLE [dbo].[tblProblem] (
[client_id] [int] NOT NULL ,
[CIU_PROBLEM_CODE_VALUE] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[CIU_PROBLEM_CODE_Colu... more >>
Problem connecting to SQL Server 2000
Posted by John Yung at 11/30/2005 12:18:17 PM
Hi,
I installed SQL Server 2005 Express on one of my development machine, I had
since then having problem connecting to a SQL Server 2000 (On a cluster)
database. The problem persist even after I remove SQL Sever 2005 Express.
The following is the error message:
SAC.EDS.CorpAction.Withholdi... more >>
Finding Consecutive Values
Posted by carmaboy NO[at]SPAM gmail.com at 11/30/2005 12:16:26 PM
I'm stuck in trying to find out how to solve this.
Within a record set, I need to know when a id has been a certain value
for x consecutive years. For example,
Create table #Test (
tid int NOT NULL,
yr int NOT NULL,
value int NOT NULL)
insert into #Test values (100, 1998, 0)
insert... more >>
debug a stored procedure in SQL Server 2005
Posted by Jaime Lucci at 11/30/2005 11:47:25 AM
Hi everyone!
How can I do to debug a Stored Procedure in SQL Server 2005 from SQL Server
Management Studio? I looked for the Debug... option when I right-clicked the
SP but it seems that in SQL Sever 2005 doesn't not exist.
Thanks.
Jaime Lucci
... more >>
Adding a DTS package
Posted by John at 11/30/2005 11:27:02 AM
Can a DTS package be added to a server via the command line using OSQL?
Thanks in advance
John
... more >>
Types of parameters
Posted by bubix at 11/30/2005 11:25:05 AM
Hello,
Can we have a inputoutput parameter, in a stored procedure??
An if it can, how declare it???
Thanks.... more >>
CHAOS
Posted by Andre at 11/30/2005 11:06:05 AM
How come there is a Chaos isolation level in the Advanced tab in DTS package
properties? Was someone having a bad day and thought there life was in chaos?... more >>
Datediff
Posted by Steve Read at 11/30/2005 10:56:08 AM
Hello
What's the easiest way to get the number of months between two values like
this?
Present date 200505 (YYYYMM) and 199905 (YYYYMM)
Steve
Thank you... more >>
ORDER BY in views - difference in 2005 vs 2000?
Posted by Andy Barnhart at 11/30/2005 10:48:04 AM
I am no SQL wizard, so if I have a flawed basic understanding please be
blunt so I will understand...
In 2000, we set up a lot of views with ORDER BY to get records in an
expected order. If I had ViewA and it contained an order by for Field1, then
if I did "SELECT * from ViewA" in SQL Ser... more >>
SQL 2005 + Row_Number() question
Posted by Ron West at 11/30/2005 10:36:13 AM
Is there a away to determine how many elements would have been returned
without out running a seperate count, even though the outer query was
filtered by rownumber?
Here's a quick sample:
Declare @Start int,@RecordsToReturn int
Declare @NameList table (NameId int)
Select @Start=0,@Records... more >>
BCP import - remove quotes from CSV File
Posted by Joey Martin at 11/30/2005 10:29:50 AM
My bcp process is now working. FINALLY.
But, my import data file is comma-delimited and everything is surrounded
by quotes; therefore, they data goes into the SQL databases with quotes.
Any suggestions on how I can remove these quotes, either before,during
or after the BCP process?
Samp... more >>
Stored procedure and UDF
Posted by Ibrahim Mesbah at 11/30/2005 10:25:04 AM
I have a function that does some processing, and returns a row of data in the
form of a TABLE. I also have a stored procedure, that iterates through a
table, and calls the UDF for each row (using a cursor), and returns a TABLE
of results where each row is the ouput of the UDF.
I need to us... more >>
Update Query for Updating Salaries
Posted by Drew at 11/30/2005 10:24:01 AM
We are getting a raise here at work, and I need to update all the salaries
to show this raise. This was easy last year, because it was just a raise of
3% so I just updated the salary field like this,
UPDATE FiscalInfo SET
Salary = Salary * 1.03
WHERE EmpActive = 1
This worked a char... more >>
Getting DISTINCT values
Posted by AccessNewbie at 11/30/2005 10:14:48 AM
I could use some help on a SELECT statement. I have two tables -
Organization and PR.
Organization has 41 distinct records.
PR has 11,168 records. One of the fields in PR ("Org") is a foreign key to
the "Org" field in Organization.
I want to return "org" and "name" from Organization for any... more >>
Soundex of each element of a string - plase help!
Posted by almurph NO[at]SPAM altavista.com at 11/30/2005 9:40:42 AM
Hi everyone,
I have a cursor which extracted a field as a nchar of size 3000. The
field has a form like:
WordA WordB WordC WordD
I want to extract each word and apply the soundex function on it to
obtain the value. Then I want to rejoin the soundex values into a
string of the form:
... more >>
Whats the wrong in this SQL?
Posted by vsr at 11/30/2005 9:31:04 AM
SELECT TOP 99 * FROM #TempExt
WHERE eFolderID NOT IN
(SELECT TOP 3564 eFolderID FROM #TempExt ORDER BY service_requested ASC
,sContractName ASC) ORDER BY service_requested ASC ,sContractName ASC
Its not ORDER BY as intended , the out put i am looking is ....first the
result should be ord... more >>
Pivot Query Example - does one exist with Datasource available?
Posted by Daniel Regalia at 11/30/2005 9:30:05 AM
Hi All,
I posted an earlier question here a week ago, it was never answerd.. I'll
try to simplify it a bit.
I need to get an example of a Pivot Query, with a datasource. i've looked
at alot of them online, and They don't really make sense...either they're too
general, or they're witho... more >>
Display records in a particular order
Posted by snigs at 11/30/2005 9:24:54 AM
Hi,
I want to display the result set of a query in a particular order.
My query looks like this -
SELECT col1,col2,col3,col4
FROM tab1
WHERE
(col2 = 1) AND (col3 = 1) AND (col4 = 5)
OR
(col2 = 1) AND (col3 = 1) AND (col4 = 3)
OR
(col2 = 1) AND (col3 = 1) AND (col4 = 1)
OR
(col2 ... more >>
Select Distinct - URGENT
Posted by Phil at 11/30/2005 8:30:06 AM
Hi All,
It may be getting a bit late in the day but I just cant seem to get the code
for a very simple select, I have a table with 100 rows in it and I do a
select distinct into a temp table and I have 50 rows in it, I now want to see
the rows that were duplicated, is this possible or am I ... more >>
How to speed up a trigger
Posted by hroussel_at_delphes.com NO[at]SPAM hotmail.com at 11/30/2005 8:22:08 AM
Hi!
I have a trigger on a table that record the number of time an insert
is done on a particuliar row. It look like this:
CREATE TRIGGER CountInsert ON mytable
INSTEAD OF INSERT AS
BEGIN
IF SELECT COUNT(*) FROM mytable INNER JOIN INSERTED ON mytable.pk_key =
INSERTED.pk_key
INS... more >>
Soundex of column fields - please help!
Posted by almurph NO[at]SPAM altavista.com at 11/30/2005 7:57:56 AM
Hi everyone,
I need to write a stored procedure that takes each row in a column
called "variations"
A typical field in the "variations" column takes the following form:
Dublin, Baile Atha Cliath, Atha Cliath, Co. Dublin, Dublin City, Dub,
dublin
and produce an outcome like:
D145 B... more >>
running scripts
Posted by mike at 11/30/2005 7:57:02 AM
Users get monthly data disks that need to be imported into our system. There
are a variety of different versions of these disks, so during the import I
need to build a version-compliant temp table to house the incoming data. I'd
like to store the DDL for each version in different text files th... more >>
BCP Import file - how to ignore top line
Posted by Joey Martin at 11/30/2005 7:39:45 AM
I have an earlier issue that has now been resolved, but now I am dealing
with a CSV file that is causing problems with my BCP import.
The csv file has column headers in the first row. Unfortunately, they
have spaces in the labels and the BCP utility cannot handle it. My BCP
command line says t... more >>
CREATE script that filters out empty columns
Posted by demf at 11/30/2005 7:11:50 AM
All:
Say I need to duplicate a table, but the CREATE script must only
include those columns of the table where the value in ALL the available
rows is not null. For an ad-hoc exercise (one or two tables), this is
easy, but for duplicating, say, 90 tables with the empty columns
filtered out, I ... more >>
Running 2 queries inside third query
Posted by sfrvn NO[at]SPAM earthlink.net at 11/30/2005 7:02:21 AM
Good morning, all.. your mission today (if you accept it) is to
decipher what I am trying to do and offer assistance to the poster.
(me!) I have searched newsgroups but can find no topics similar to my
needs.
Background:
Trying to create a 'dqy' (MS Query) file for distribution to field
pe... more >>
Pulling out table and column descriptions
Posted by Mike Collins at 11/30/2005 5:50:07 AM
When I run the following query:
Select * From Information_Schema.columns Where TABLE_NAME = 'Answers'
I see that, for my table "Answers", I have 9 rows returned, showing each
field in my table.
The sysobjects query shows where I can get the Id for Answers and use it for
getting the fie... more >>
BCP Help - Going Crazy!!!!
Posted by Joey Martin at 11/30/2005 5:49:50 AM
I have successfully used BCP before. But, this time, I have an entirely
new import csv file and it's causing me so much trouble. I am working
with a CSV file with more fields than the SQL table but I am following
what BOL tells me to do. PLEASE HELP!!!
ERROR: Incorrect host-column number found... more >>
|