all groups > sql server programming > may 2007 > threads for wednesday may 16
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
sql 2005
Posted by lionel luo at 5/16/2007 11:31:17 PM
hi, I want to run a update query in a remote machine running sql 2005. how
to do that, use isql like sql 2000 or other good ways? Thanks.
... more >>
Should I use dynamic SQL to combine 2 procs into 1?
Posted by Ronald S. Cook at 5/16/2007 11:08:12 PM
For dozens of entities, I have a Select (returns one record with @ID param)
and a SelectList (returns all records.. no param passed) stored procedure.
E.g...
CREATE PROCEDURE dbo.SelectEmployeeList
AS
SELECT *
FROM Employee
CREATE PROCEDURE dbo.SelectEmployee
@EmployeeID uniqueidentifi... more >>
Why do I get different results using these two approaches
Posted by Nigel A at 5/16/2007 11:03:31 PM
I am trying to reconcile some data across two SQL servers. The tables being
queried in each server are supposed to be in sync as regards invoice numbers
and amounts.
I have querys A, B & C
A)
select sum(amount) from [ANOTHER].[SQLSERVER].[dbo].[Paid Billing]
where [date applied] >= '2007... more >>
View of table and column names in a DB using 2005
Posted by Rob at 5/16/2007 10:56:20 PM
Using sql 2005
I would like to create a listing of all the tables, column names, and column
types in a database.
It does not look like I can build a view using the system tables any more
(as was done in 2000) ?
Thanks !
... more >>
Update set increment value
Posted by Iman at 5/16/2007 8:53:22 PM
Hi,
Say I have this data:
id name
null John
null Joe
null Jack
Is there a simple sql i can use in my update statement? No procedure,
sequence object, etc. Just sql.
Tried below but didn't work:
update table
set ID=(SELECT COALESCE(ID),0)+1 FROM table)
Any input appr... more >>
Select one or all in the same proc?
Posted by Ronald S. Cook at 5/16/2007 8:01:13 PM
I'd like to do something like the below (that would eventually be in a proc)
but with null instead of 0. I'm not sure why replacing 0 with null doesn't
work. Also, I'm thinking I should build with dynamic SQL or something so I
don't duplicate stuff I don't need to?
DECLARE @ID int
SET @I... more >>
Keeping databases in sync...
Posted by hurricane_number_one NO[at]SPAM yahoo.com at 5/16/2007 6:47:16 PM
I'm looking to have a database at a central location be in sync with
another database at another location over the internet. I want to be
able to have the data at the central office mirror the other location
in as close to real time as possible, preferably they wouldn't be out
of sync by more th... more >>
WITH [Table] versus temp table
Posted by Marc Castrechini at 5/16/2007 4:00:44 PM
This is a hard one to find online because searching for WITH isn't exactly
easy.
Does anyone have an explanation or a reference that may explain:
1) What the WITH statement really does
2) What the pros and cons are of using it versus temp table syntax
examples:
WITH TempTable AS
(Sel... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Find First AlphNumeric Char in a Field value
Posted by RickSean at 5/16/2007 2:28:01 PM
CREATE TABLE [dbo].[Category](
[CatID] [smallint] NOT NULL,
[CatDesc] [nvarchar](16) NULL
CONSTRAINT [Category$PrimaryKey] PRIMARY KEY CLUSTERED
(
[CatID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
insert into dbo.Category values('1', ... more >>
Changing data type on a column
Posted by scuba79 at 5/16/2007 2:07:02 PM
I need to change the datatype of a column from int to bigint. The column is
the identity column of the table and the table does have about 3 million
records in it.
How can I do this?
I'm trying to use the following statement but keep getting an error message,
saying "Incorrect syntax ne... more >>
Best Fit
Posted by Mike C# at 5/16/2007 1:53:50 PM
Here's an interesting problem that I'm trying to find a set-based solution
for. Let's say I have two tables:
CREATE TABLE OrderDetail (OrderNum INT NOT NULL,
OrderLine INT NOT NULL,
ItemID INT NOT NULL,
Quantity INT NOT NULL,
PRIMARY KEY (OrderNum, OrderLine))
CREATE TABLE Inventory... more >>
Finding a number in a string
Posted by VMI at 5/16/2007 1:30:41 PM
How can I find a number in a string? For example, myTable.code equals
"AB99". I would need to update myTable.Alpha to "AB" and myTable.Num would
be updated to "99". Is this possible?
Thanks.
... more >>
stored procedures scripting
Posted by iiman at 5/16/2007 1:16:50 PM
I had created about 30 new stored procedures on my development machine (i am
using SQL Server 2005). In sql server 2000, you were able to select
multiple stored procedures and generate sql scripts and with one swoop, you
were able to transfer stored procedures in the production box. It seems... more >>
Return Field Name as data
Posted by Fayven Wren at 5/16/2007 12:55:43 PM
I have a table similar to the one shown here:
Counter Q1 Q2 Q3 Created
----------- ------- ----- ------ --------------
1 1 2 3 5/1/2007
2 2 3 4 5/2/2007
3 3 4 5 5/3/2007
... more >>
select rows from specific groups problem?
Posted by Rich at 5/16/2007 11:59:01 AM
I need to select entire rows from the dataset below where each recID group
contains at least one row where NR = 'n'. In the group of rows for recID =
345, none of the rows from this group contains NR = 'n', so I need to exclude
the rows from this group. What query will retrieve the desired ... more >>
3 views becoming unweildy
Posted by riyaz.mansoor NO[at]SPAM gmail.com at 5/16/2007 11:43:24 AM
Hi
Table T_VesselRoute { VR_VesselTrip, VR_DateTime, VR_Distance } --
shortened of course
For Each { TODAY, TODAY+1, .. TODAY+6, REST }
need COUNT(VR_VesselTrip), COUNT(VR_DateTime), SUM(VR_Distance)
I have attempted the following solution. I'm a SQL newbie and was
wondering if th... more >>
How to select column values with percentage mark %?
Posted by tanya.wang NO[at]SPAM gmail.com at 5/16/2007 11:23:21 AM
Being a very newbie I have some questions regarding the select
statement with % .
As we know that the % is used for getting approximated values in the
select statement. I wonder how I should use the % mark if I am going
to grab column values with % themselves.
For example, the NAME column i... more >>
Updating non-ASCII characters with '' in a string
Posted by nadimpalli.pavan NO[at]SPAM gmail.com at 5/16/2007 11:05:52 AM
Hello Everyone, I am trying to replace non-ASCII characters with a ''
in a text column.
I wrote a stored procedure to do this, using the following code.
begin
if unicode(substring(@old_string, @count, 1)) < 127
begin
set @new_string =3D @new_string+substring(@old_string, @coun... more >>
Obtaining Stored Proc and Trigger text
Posted by Michel Racicot at 5/16/2007 11:01:03 AM
How can I obtain a strored procedure or a trigger text in SQL Server 2000?
I'm pretty sure that the code should be stored in a memo somewhere in a
system table, right?
The reason for this is that I want to "compare" the code of my stored
procedures and triggers with the code it should cont... more >>
Is a Conditional Join Possible?
Posted by RitaG at 5/16/2007 10:52:00 AM
Hello.
I'm inserting rows into a table. Depending on the value of Table1.CodeType I
need to Inner Join to another table. If Table1.CodeType = "A" and "B" I need
to Inner Join to another table. If Table1.CodeType = "C" then the Inner Join
is not required. Rather than doing two inserts, one w... more >>
Complex counting, summing and grouping
Posted by Patrick at 5/16/2007 10:25:03 AM
I have a table of Sales statistics as follows, with each record bearing
invoiceID, salesRep who contributed towards the sales, the SalesDepartment of
the salesRep and the SalesAmount the SalesRep contributed
Create Table
sales (invoiceID INT NOT NULL,
salesRepID INT NOT NULL,
Sales... more >>
Failed BCP Process in SQL Server 2005
Posted by Ken Sturgeon at 5/16/2007 9:52:22 AM
In a SQL 2000 database the following BCP command runs successfully. It =
essentially reads from the ELIGDATA1 table in a database named GW301 and =
puts all of the data from that table into a file named eligdata1.txt.
EXECUTE master..xp_cmdshell "BCP GW301..ELIGDATA1 OUT =
F:\Data\eligdata1.tx... more >>
Weekly Totals
Posted by rich at 5/16/2007 9:17:53 AM
Hi,
I'm logging some production totals every day in a table. I've managed
to use the query below to give me monthly totals how can adapt it to
give me weekly totals. Unforunately there doesn't seem to be a week
function?
SELECT MONTH(Date) AS Month, SUM(Total3) AS Production
FROM ... more >>
Help with SELECT FROM DAY(CURRENT_TIMESTAMP)
Posted by Trev at 5/16/2007 9:03:26 AM
Hi
can anyone put me right here I would like to open an access 2003
database by its date using sql. I have a table created each day and
renamed by that days date.
this is what i have so far but it does not work. please help
Call BarGraphSQLData( _
"SELECT id, DataReading FROM DAY(CURR... more >>
Problem with JOIN
Posted by ITDUDE27 at 5/16/2007 8:49:02 AM
Hello world,
I have a proble with a stored procedure I'm working on. I am selecting data
from 2 different views which stores invoice data.
The select statement is joining the 2 view by Invoice_NO (INNER JOIN). the
stored procecude has some ackward results. Every x number of displays the
... more >>
datepart question
Posted by marcmc at 5/16/2007 8:35:40 AM
select datepart(mm,CAST(getdate() as varchar))
is 5
How can I get
'May'... more >>
Somebody used Keyword OBJECT_ID as a column name...
Posted by sparker at 5/16/2007 8:00:01 AM
The Transact-SQL Reference for OBJECT_ID
Returns the database object identification number.
What are the Consequences of Using Reserved Keyword OBJECT_ID as a column
name in SQL Server 2000?
Has anybody out there ran into any problems where somebody named a column
OBJECT_ID?
If so woul... more >>
History for 1 extract table.
Posted by YYZ at 5/16/2007 7:54:19 AM
Hello folks. I really have tried searching on this, but couldn't find
an exact scenario that corresponds to my situation.
I've got 1 table that I'm concerned with right now. It's called
LoanSummary. It contains a bunch of fields, but for ease let's assume
just a few columns, LoanNumber, Dat... more >>
Query Help
Posted by Rick at 5/16/2007 7:42:02 AM
Here is sample table and data.
Create Table Data
(DataKey int identity (1,1) not null,
DataPeriod smalldatetime not null,
DataValue real null,
DataFlag null)
insert into Data values('2007-01-01 00:00:00', 19.2, null)
insert into Data values('2007-01-01 00:03:00', 18.2, null)
insert into ... more >>
concatenation
Posted by nj at 5/16/2007 7:21:39 AM
need assistance.
create table t1( c1 int , c2 int , c3 char(2) )
insert into t1
select '1','1','one'
union
select '1','2','two'
union
select '2','1','three'
union
select '2','2','four'
union
select '3','1','five'
union
select '3','2','six'
desired output :-
c1 c3
1 ... more >>
How to select the latest timestamped record?
Posted by nisheeth29 at 5/16/2007 6:30:01 AM
Hello!
I have this OpportunityHistory table (pasted at the end) which has snapshots
in time of the field OpportunityId with a CreatedDate datestamp and an
associated Amount. So the OpportunityId can appear more than once in the
table and together with the CreatedDate defines a unique record... more >>
rewrite NOT EXISTS to LEFT OUTER JOIN
Posted by eteunisse at 5/16/2007 6:17:11 AM
LS,
I read some earlier articles which explain how to rewrite a query with
a not exists sub query to a query with an outerjoin. I did not
succeed.
Can some one give me a hand with this?
The query I want to rewrite is:
select
instrument_id,
ODS_TB_STAG_SD_A_INTADJUST.int_date as int... more >>
Need help setting up Backup Maint Task
Posted by Tracy at 5/16/2007 6:01:02 AM
I have created a daily database Maintenance Plan in Enterprise Mgr using the
wizard.
However the Job does not appear to run and I am not sure what is going on.
Can anyone tell me what to check for or any bright ideas. I am completely
new to SQL and so I am stubling a little. I am using Ente... more >>
SQL Server Solutions BLOG
Posted by Namwar at 5/16/2007 4:55:00 AM
Hi everyone,
I have a blog at
http://blog.namwarrizvi.com/
focusing specifically on TSQL programming and day to day issues. Some of
the recent posts include:
Removing Duplicates Rows
Case Sensitive string comparison in SQL Server 200...
Secure Your Data: Simple solution to Encrypt... more >>
XML Problem
Posted by acx NO[at]SPAM centrum.cz at 5/16/2007 4:02:38 AM
Hi,
I am new to SQL Server so excuse me for this stupid question. I have
got some XLM code which I want to send on some remote application
server via POST method. The server will return XML code as well.
I can't find a proper T-SQL command(s) which I could use to send XML
on the server by... more >>
How to Fix Error 207 in SQL SERVER 2000 with out using Service Pack SP4.
Posted by Eckhart at 5/16/2007 3:45:15 AM
How to Fix Error 207 in SQL SERVER 2000 with out using Service Pack
SP4.
... more >>
Stored procedure evaluating a query passed as param
Posted by Ale at 5/16/2007 3:10:11 AM
Hi,
i need to create a stored procedure which execute (evaluate) a query
string passed as param. Is it possible?
The query is an update or a create query, so i don't need any return
result...
Thank you.
Ale
... more >>
How to count number of commas.
Posted by Geir at 5/16/2007 12:41:00 AM
Hi all.
In a varchar(8000) i get a list delimited by commas. I want to know how many
items it is between the commas or just count commas + 1.
Declare @List varchar(8000)
Set @List = '100065, 100039, ¤, 100191'
I want the result 4 in an easy way.
best regards geir
... more >>
Calculated Balance Value
Posted by vovan at 5/16/2007 12:00:00 AM
I have AccountRegister table in SQL 2000 database with the following fields:
ID, EntryDate, DebitAmount, CreditAmount and let's say values are:
1 04/01/2007 100.00 NULL
2 04/02/2007 110.00 NULL
3 04/03/2007 NULL 25.50
4 04/... more >>
Create Procedure question
Posted by Jeff Law at 5/16/2007 12:00:00 AM
I am trying to convert a heap of Access queries to SQLServer, but am stumped
as to why the following two have errors. I didn't write the original Access
queries so am trying not to radically change them.
1. This one doesn't like the '*', so I replaced MECRMapping.* with the
actual field nam... more >>
Index on View with Count
Posted by Lasse Edsvik at 5/16/2007 12:00:00 AM
Hello
I have a slight problem, I have a view created in sql 2005 that has 5 tables
joined, and a column that counts records from another table. But it's
impossible to add an index on it since its a subquery, what to do? feels odd
that its not doable to count and put an index on it, its 2007 af... more >>
Stored procedure assist
Posted by Peter Lux at 5/16/2007 12:00:00 AM
I'm trying to finish up this project and I'm getting a very frustrating
error just trying to update the status on the main table AFTER I'm done
processing. I have 3 stored procs, one invokes the other 2 depending on
whether the "paying" company matches the "charge" company. It all runs fine
... more >>
|