Wednesday, March 28, 2012
Problems in SQL, Updating many rows at once
I have a person table. The relavent columns are:
PersonID INT
LastName VARCHAR(30)
LastNameSndx CHAR(4)
I'm almost embarressed to ask considering my SQL expertise, but...
I need to take the SOUNDEX of the LastName and put that value in the LastNameSndx column. So I fire off this SQL:
Update Person Set LastNameSndx = SOUNDEX(LastName);
It takes forever. I start tweeking the SQL to commit every 500 records or so. Still takes a long time. I then notice what is happening. The SQL is taking the SOUNDEX of the LastName of the first record, apply it to ALL the records, then taking the SOUNDEX of the LastName of the second records, then updating it to ALL the records, etc.
This is not SQL as I understand it.
What am I doing wrong here?Hi!
> It takes forever. I start tweeking the SQL to commit every 500 records or
so. Still takes a long time. I then notice what is happening. The SQL is
taking the SOUNDEX of the LastName of the first record, apply it to ALL the
records, then taking the SOUNDEX of the LastName of the second records, then
updating it to ALL the records, etc.
>
How did you notice this? This is really strange, I've never heard of
something like this.
--
Dejan Sarka, SQL Server MVP
Please reply only to the newsgroups.|||I attempted the same thing and I am not seeing the same behavior. Not sure
what is happening in your case.
Rand
This posting is provided "as is" with no warranties and confers no rights.
Problems importing data into sql server
(firstname, lastname, etc.) and an author_id field (set as identity)
I'm trying to import a spreadsheet into this table, but keep getting
error messages that say I can't import data into the author_id field
(the identityf field).
Can someone suggest what I can do to overcome this?
Thanks,
Bill1) Import the data into a new flat table (ie: without indexes).
2) Run a report on the key field (identityf) -- there must be no duplicates.
select indentityf, count(*)
from newtable
group by identityf
having count(*)>1
should yield no results.
3) Correct the spreadsheet.
4) reimport the spreadsheet.
"Bill" <billzimmerman@.gospellight.com> wrote in message
news:8da5f4f4.0312091329.c066e47@.posting.google.co m...
> I have a table for authors (for our bookstore) that has several fields
> (firstname, lastname, etc.) and an author_id field (set as identity)
> I'm trying to import a spreadsheet into this table, but keep getting
> error messages that say I can't import data into the author_id field
> (the identityf field).
> Can someone suggest what I can do to overcome this?
> Thanks,
> Bill|||"Bill" <billzimmerman@.gospellight.com> wrote in message
news:8da5f4f4.0312091329.c066e47@.posting.google.co m...
> I have a table for authors (for our bookstore) that has several fields
> (firstname, lastname, etc.) and an author_id field (set as identity)
> I'm trying to import a spreadsheet into this table, but keep getting
> error messages that say I can't import data into the author_id field
> (the identityf field).
> Can someone suggest what I can do to overcome this?
<snip
Use the DTS. On the screen that allows you to select the tables, click the
Transform button. On this screem, you'll see 'Allow Identity Insert'.
BV
www.iheartmypond.comsql
Friday, March 9, 2012
Problem: render a report which should show data in coulmns
I'm designing a report which contains a sub report. The sub report show a
list of data (firstname, lastname).
I'm tyring to display data separated by columns.
When you use the report Item "List" there is only the possibility to use a
page break before or after.
Is there a way to use or implement a kind of "column break" ?
ThanksIs it possible to change the query which displays your subreport?. if yes why
cant you change the query by just adding something like this.
select firstname, ' ', lastname .......
Amarnath
"Joes" wrote:
> Hello,
> I'm designing a report which contains a sub report. The sub report show a
> list of data (firstname, lastname).
> I'm tyring to display data separated by columns.
> When you use the report Item "List" there is only the possibility to use a
> page break before or after.
> Is there a way to use or implement a kind of "column break" ?
> Thanks
>
>
Saturday, February 25, 2012
Problem with using 'OutPut Clause' in SQL SEERVER 2005
Hi everyBody,
I Tried to use "OutPut" clause in insert statment as fallows:
insert into test
OUTPUT Inserted.Name,Inserted.LastName
values ('John','kransky')
The Error:
Line 2: Incorrect syntax near 'OUTPUT'.
but I face with this error,I checked MSDN and the other sources, it seems everything is ok. But when I run it ,I face with that error message.I would be appriciate if someone help me on it.
OUTPUT values MUST be 'captured' in some fashion. Typically, the OUTPUT values are captured in a @.Temp table.
For Example, this might work for you:
Code Snippet
DECLARE @.NewRows table
( [Name] varchar(20),
LastName varchar(20)
);
INSERT INTO Test
OUTPUT Inserted.Name, Inserted.LastName
INTO @.NewRows
VALUES ( 'John', 'kransky' );
Then you can use the data in the @.NewRows table however you wish.
Problem with using ''OutPut Clause'' in SQL SEERVER 2005
Hi everyBody,
I Tried to use "OutPut" clause in insert statment as fallows:
insert into test
OUTPUT Inserted.Name,Inserted.LastName
values ('John','kransky')
The Error:
Line 2: Incorrect syntax near 'OUTPUT'.
but I face with this error,I checked MSDN and the other sources, it seems everything is ok. But when I run it ,I face with that error message.I would be appriciate if someone help me on it.
OUTPUT values MUST be 'captured' in some fashion. Typically, the OUTPUT values are captured in a @.Temp table.
For Example, this might work for you:
Code Snippet
DECLARE @.NewRows table
( [Name] varchar(20),
LastName varchar(20)
);
INSERT INTO Test
OUTPUT Inserted.Name, Inserted.LastName
INTO @.NewRows
VALUES ( 'John', 'kransky' );
Then you can use the data in the @.NewRows table however you wish.