all groups > sql server programming > may 2007 > threads for friday may 18
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
Cannot design query.
Posted by riyaz.mansoor NO[at]SPAM gmail.com at 5/18/2007 11:00:52 PM
Hi
My sql is quite basic. Please bear with me.
table Fueltbl { fBoat, fDate, fVolume, fPrice }
table Movementtbl { mBoat, mDate, mDistance }
per boat, per month, i need sum(fVolume), sum(fPrice), sum(mDistance)
ie: view { boat, date(month-year), sum(fVolume), sum(fPrice),
sum(mDistance... more >>
Dynamic Query Syntax
Posted by Bil Click at 5/18/2007 8:24:01 PM
This sproc is called from Vb.NET code with different outputTable and
countyname values. Keep getting error: Must declare the scalar variable
"@countyname".
ALTER PROCEDURE [dbo].[_spInsert_output_all2]
(@outputTable nvarchar(32),
@countyname varchar(25))
AS
DECLARE @SQL Nvarchar(100... more >>
Append/Update to table when view created
Posted by DavidT at 5/18/2007 5:01:12 PM
I am trying to use data from an IBM/DB2 database to update tables in a SQL
2005 database.
The IBM/DB2 database is used to create purchase orders and purchase order
line items (PO table) and to receive quantities of ordered parts (RECV table).
I want to use the data in those tables to create... more >>
Problem after detach on one machine and attach on another
Posted by JsWhal NO[at]SPAM gmail.com at 5/18/2007 3:32:31 PM
I have a SQLExpress database that I move from one PC to another. When
I attach it to the 2nd machine, my application cannot login. I have to
delete the user from the database that I moved, then go to the
Security->Logins tab of the server and select the user there. I then
select Server Mapping a... more >>
DateDiff() for years
Posted by GrowlTiger at 5/18/2007 3:05:01 PM
I have 2 date fields that I need to calculate the number of years between. I
thought I could use "datediff(year,date1,date2)" but that doesn't seem to be
working correctly. For example, using the statement
select datediff(year,'12/31/2006','01/01/2007')
yields a result of 1 year when cle... more >>
SQL 2000 FK On Delete Set Null?
Posted by Carlo Razzeto at 5/18/2007 2:34:54 PM
You can do the above in sql 2005 with references <table>(<column>) on delete
set null, this syntax doesn't seem 2000 compatible. And I can't find
anything in 2000 that works. Anyone know how to acomplish this?
... more >>
bulk insert fixed width file ?? The column is too long in the data file for row
Posted by jobs at 5/18/2007 1:49:25 PM
sample input looks like this (175 width):
42500107043000000000000000000000000000000199500000000000000000000000000000000000000000007000004504020000000000009732911988
00005 KUJ12800000030000000001000000
my table:
create table x_lpold(
garbage1 varchar(112) null,
xkey varchar(10) null... more >>
bulk insert skip header and trailer records
Posted by jobs at 5/18/2007 1:22:46 PM
I see the skiprow command in bulk insert. How do I skip the last row?
Thanks for any help or information.
... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Delete Global Temp variable (##Temp)
Posted by loufuki NO[at]SPAM gmail.com at 5/18/2007 1:04:29 PM
Hi,
I created a Global Temp variable in one SP and use it in a second SP
and then delete it from the second SP.
However, it is still existing in the DB.
What is the problem?
am I doing it correctly?
Thanks
... more >>
find actual temptable name specific to @@spid?
Posted by Liam Caffrey at 5/18/2007 12:16:12 PM
Hi,
How do I find the actual name of temp table that I create on my
connection if there are multiple temp tables of the same name as
created by the same stored procedure by other users. (i.e. without the
128 char right pad unique string)
I can find the name if I am the only connection that ... more >>
Omit 0-values from join
Posted by Eiriken at 5/18/2007 12:04:58 PM
Hi all,
I have some problems with a sql-statement, and I appreciate all help I
can get.
I have a table MyTable with four columns col1, col2, col3, col4
each column is of type Int. Below is the table with some sample
values.
Col1 Col2 Col3 Col4
2 3 1 0
... more >>
make NULL values = 0
Posted by geoffa at 5/18/2007 10:36:02 AM
is there anyway to make NULL values = 0 (zero) in a temp (#temp) table?... more >>
Service Account Lockout
Posted by Alien2_51 at 5/18/2007 9:54:02 AM
We have a production and deveoplment environment each in a seperate AD
domain, each environment has many servers. All the sql servers run under the
same AD domain account in each respective domain. We are seeing the
production account being locked out from a server in the development domain.
... more >>
Tough problem: can this be done using parameterized stored procedures?
Posted by es330td at 5/18/2007 9:05:05 AM
We have a web application with a search form. The search form has
been constructed with the ability to search on up to 5 different
values for a given column and the souces include 6 different tables.
There are many (about 15 different things) that can be searched on.
The behavior of the page is... more >>
removing duplicate rows - keeping the highest value row
Posted by jobs at 5/18/2007 8:32:14 AM
I have a table that looks like this:
create table x1(
f1 varchar(50) null,
f2 varchar(50) null,
f3 varchar(50) null,
f4 varchar(50) null,
f5 varchar(50) null,
f6 integer,
f7 varchar(250) null
);
I want f1 to be unique and would like to keep the row with the highest
f6.
Thanks for a... more >>
ALTER TABLE weird behaviour
Posted by ewest305 NO[at]SPAM comcast.net at 5/18/2007 8:26:57 AM
I gotta be doing something wrong:
BULK INSERT [CUSTOMERS]
FROM 'MyFile.txt'
GO
ALTER TABLE CUSTOMERS
ADD LINENUMBER INT NULL
GO
UPDATE CUSTOMERS
SET LINENUMBER = CONVERT(INT, SUBSTRING(DATALINE, 1,
CHARINDEX(CHAR(9), DATALINE) - 1))
The third statement (UPDATE CUSTOMERS) SOMETIMES ... more >>
String Manipulation in 2005
Posted by RickSean at 5/18/2007 7:59:03 AM
CREATE TABLE [dbo].[Category](
[CatID] [SMALLINT] NOT NULL,
[CatType] [nvarchar](16) NOT NULL,
[Cat1] [nvarchar](16) NULL,
[Cat2] [nvarchar](16) NULL
CONSTRAINT [Category$PrimaryKey] PRIMARY KEY CLUSTERED
(
[CatID] ASC,
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ... more >>
bulk insert rowterminator unix files - An unexpected end of file was encountered
Posted by jobs at 5/18/2007 7:50:39 AM
I ftped a unix file to my sql server windows server.
flat file records look like this:
1237725771;200703;000295;000026;20040701;20101231;SOME TEXT HERE
when i look at the file in hex, is a 0A0D at the end of the file.
my work table is defined as such:
drop table x1
go
create table x... more >>
Search for text in a database
Posted by Rob at 5/18/2007 7:48:04 AM
Is there a simple way to seach through all the tables and columns in a given
database for a string of text held as a value...
I do not care how long the search takes to run. Also, this would not be
employed on a production database.
It looks like the full text search carries a good bit of... more >>
bulkinsert and creating columns on the fly?
Posted by jobs at 5/18/2007 7:29:11 AM
sorry for the noob question.
I'm looking to use sql server to compare two files that that are
semicolon deliminated. The files are pretty big.
If i'd like to keep the tables around for a few weeks, but I don't
really care about column names as I'm only playing.
Do i have to manually do th... more >>
A question related to stored procedure
Posted by babu at 5/18/2007 7:09:11 AM
Suppose there is a database table which contains information of a
complete binary tree.
A complete binary tree is always populated depth wise. A certain level
is filled up completely before going further level
down.
The table contains sequential information of the tree. As shown in the
fol... more >>
New to SQL, where to start?
Posted by Mike at 5/18/2007 6:46:01 AM
Hi folks,
I'm looking for advice. My company wants me to create a custom client
tracking program, and I think the best way to do this is with SQL and Access.
However, I've never created a DB from scratch. I'm looking for learning
advice. Any book, web site recommendations for someone ne... more >>
Totals
Posted by rich at 5/18/2007 6:42:39 AM
Hi,
I have a table that is populated everyday with daily totals, I'm
trying to teach myself SQL using this table.
Someone kindly gave me a query that gave the weekly totals based on
the table:
SELECT week_start, week_start + 6 AS week_end, SUM(Total3) AS
production
FROM (SELEC... more >>
Question on SQL Server SQL
Posted by datapro01 at 5/18/2007 6:32:29 AM
In DB2 one can issue a query like
db2 -x 'select tabname from syscat.tables'
and the output is cleaned up so all you get is/are the requested table
name(s)...no dotted lines...no column headings.
Does SQL Server have a similar construct?
Thanks
Gerry
... more >>
Tricky TSQL question
Posted by Liz at 5/18/2007 5:43:01 AM
How can I create the following 2 sql selects with a union into just one query?
select *
from TableA a
where exists (select nbr from TableB b where a.id = b.id)
UNION
select *
from TableA a
where exists (select nbr from TableC c where a.id = c.id)
If I use both "where exists" in the s... more >>
SQL Query Help
Posted by vrao5090 NO[at]SPAM sbcglobal.net at 5/18/2007 4:53:13 AM
Hello:
Need to learn SQL queries again (SQL 2005). Need help with the
following situation:
I have two tables, CUSTOMERS and ORDERS. One each column in these
tables should have identical data (except the name of the column is
different) which is customer's name. Because each order creates ... more >>
How to select every "n"th row
Posted by Andrew Wright at 5/18/2007 2:17:00 AM
How can i return every "n"th row from a dataset? So I have a dataset I then
want it to return every "n"th row eg, 4,9 etc dependant on the user input.
Its on SQL 2000. Are the any functions etc that I can use for this?
Rgds
Andy
... more >>
finding job history
Posted by vikrenth at 5/18/2007 12:41:11 AM
is there any possible way were we can filter the jobs that have failed
yesterday using SMO and C#?
--
vikrenth
mcp... more >>
Trying to make counts per period
Posted by Arild Grimstad at 5/18/2007 12:00:00 AM
I'm having a table of "Issues" where I need to pull out counts based on
these three columns:
Ref InWeek OutWeek
R1 01 01
R2 01 02
R3 02 02
R4 02 NULL
R5 03 NULL
This means I'v received 5 issues, and 3 of those ha... more >>
Checking for an Error
Posted by gv at 5/18/2007 12:00:00 AM
Hi all,
How do I check for an error here? The code below doesn't seem to work.
I'm looping through the databases and need to check for this error. How?
I get this error:
Server: Msg 924, Level 14, State 1, Line 3
Database 'MyDatabase' is already open and can only have one user at a ... more >>
SMO: running a stored procedure in C#
Posted by Marco Shaw at 5/18/2007 12:00:00 AM
(SMO/C# novice)
I can't seem to find any examples of how one can run a stored procedure
using SMO.
I'd like something in C# (well PowerShell actually, but I'll settle for C#).
Marco... more >>
Check if all row value are in a list
Posted by Greg Jimson at 5/18/2007 12:00:00 AM
Hi,
my query return a list of names:
Peter
Mike
Joe
No I'd like to check if all results are in a list which is for example
Peter, Mike
so the the case above it should return true and
Mike
Joe
Steven
should return false.
How to achieve this?
Thanks in advance
Greg
--... more >>
Zwei Cursurs zeitgleich verwenden
Posted by Greg Jimson at 5/18/2007 12:00:00 AM
Hallo,
ich möchte gerne zwei ineinander verschachtelte Schleifen programmieren.
Dazu möchte ich zwei Cursors verwenden.
Hierzu benutze ich die Variable @@fetch_status. Woran erkenne ich, auf
welchen Cursor sich diese bezieht?
Danke für jeden Tipp
Greg
--
Greg Jimson
... more >>
index error? selet statement return nothing
Posted by Agnes at 5/18/2007 12:00:00 AM
(1) select invno,jobno from apinvinfo where ltrim(rtrim(JOBNO))
='HKL0705035'
(2) select invno,jobno from apinvinfo where invno ='MAEU854396577'
For statement(2) It return the correct result
MAEU854396577 HKL0705035
However for statement(1) , it return nothing !!!
I make sure that ... more >>
|