Friday, March 30, 2012

I'd like to get a good book of SQL...

Would all of you give me a suggestion of valuable book in terms of SQL ?

I confused what kind of SQL book is going to be good for me to study since

I begin to jump into MS-SQL...

Furthermore, I'd know that various level of book as begginer, intermediate , advance...

Thanks for your help in advance..

In my opinion the best T-SQL book is

The Guru's Guide to Transact-SQL
by Ken Henderson
http://www.amazon.com/exec/obidos/tg/detail/-/0201615762/ref=ase_sql08-20/102-4703055-5891314?v=glance&s=books

Although Ken's book doesn't deal with SQL Server 2005 you should definitely get it

You can also get Pro SQL server 2005

http://www.amazon.com/exec/obidos/ASIN/1590594770/sql08-20/102-5735017-0910517?%5Fencoding=UTF8&camp=1789&link%5Fcode=xm2 In addition to Ken's book since Pro SQL server 2005 deals with the new stuff in SQL server 2005 only

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||

I started out with Microsoft SQL Server 2005 - A Beginner's Guide by Dusan Petkovic. (ISBN 0072260939) pub. McGraw Hill.

I am a beginner to SQL Server 2005 and this book has helped quite a bit.

|||

whats better than free

http://blog.pinpub.com/archives/sqlblog/2006/01/more_sample_cha.html

sql

Id getting generated differently

Hi,

I created a PDA application with a database, which has a table with a uniqueidentifier field and primarykey.

While doing the bulk insert from dataset into sql mobile database, It is inserting the record but it is not inserting the id which was entered into the sql server 2005 database, instead the id by creating a new id and the code is as below.

conAdap = new SqlCeDataAdapter(strQuery, conSqlceConnection);

SqlCeCommandBuilder cmdBuilder = new SqlCeCommandBuilder(conAdap);

conAdap.Fill(dsData);

int r =conAdap.Update(dsData);

Please help me.

Thank you,

Prashant

Hi Prashant - I'm not sure I understand your issue. Could you explain in more detail and also give me somee information about the schema of the table itself? I'm interested in the list of columns, their types, PK, FKs, Indexes, and default values you have assigned on columns.

I'm also interested to know if the table is the product of an RDA pull with tracking on or merge replication article.

thanks,

Darren

ID for New record

Hi,
How can I insert a new record in sql table and retrun the ID of that reocrd using a stored procedure?
Thanks,From Books Online:

INSERT INTO jobs (job_desc,min_lvl,max_lvl)
VALUES ('Accountant',12,125)
SELECT @.@.IDENTITY AS 'Identity'

In stored proc:

create procedure sp_Test

@.outputvalue int output
as

INSERT INTO jobs (job_desc,min_lvl,max_lvl)
VALUES ('Accountant',12,125)
SELECT @.outputvalue = @.@.IDENTITY|||Thanks DMWCincy.|||Watch out fot @.@.IDENTITY, better use SCOPE_IDENTITY() besuase @.@.IDENTITY will return the last increment for the table, not necessarily the one that was generated by you transaction.

ID Field Reset

This morning I made a change to two tables in my live system. All I did was add a new column in each called 'suspense' with a data type of bit and a default value of '0'.

When the users started using the system they noticed that the record ID numbers had reset and were starting from 1 and going up 2, 3, 4 etc. The last good id number was about 20500. The id columns are set as primary key with identity and increment of 1.

This shouldn't happen should it? Is it a bug? I never touched the ID column, just added the new one.I bet you made the change using Enterprise Mangler. EM tends to make these changes not with a simple alter table add column, but with a drop and re-create of the table. You can try running DBCC CHECKIDENT(table) on the table, which should reset the identity column nicely.|||That's interesting. I am going to test that on my test system now to see what happens.

Thanks!

ID Edition? General MS SQL training?

I have two questions.

First is there an easy way to tell what
edition of MS SQL Server is on a machine?
I found some code that is supposed to do
this, but if I put that code into the query
analyzer, it doesn't work. (Doesn't look
like SQL query in any case.)

A more general question: Education about SQL.

I have an MS in biostats so I'm not totally
computer illiterate, but I've never programmed
anything GUI.

Thanks for any answers

Michael Young<mcl2@.vms.cis.pitt.edu> wrote in message
news:c5eton$kp4$1@.usenet01.srv.cis.pitt.edu...
> I have two questions.
> First is there an easy way to tell what
> edition of MS SQL Server is on a machine?
> I found some code that is supposed to do
> this, but if I put that code into the query
> analyzer, it doesn't work. (Doesn't look
> like SQL query in any case.)
> A more general question: Education about SQL.
> I have an MS in biostats so I'm not totally
> computer illiterate, but I've never programmed
> anything GUI.
> Thanks for any answers
> Michael Young

SELECT @.@.VERSION
SELECT SERVERPROPERTY('Edition')

The second one is only in SQL2000 only. As for education, you might want to
start with some general books on databases and the SQL language, although
Microsoft's own training material is usually pretty good. You may find some
useful information here:

http://vyaskn.tripod.com/sqlbooks.htm

Simon|||<mcl2@.vms.cis.pitt.edu> wrote in message
news:c5eton$kp4$1@.usenet01.srv.cis.pitt.edu...
> I have two questions.
> First is there an easy way to tell what
> edition of MS SQL Server is on a machine?
> I found some code that is supposed to do
> this, but if I put that code into the query
> analyzer, it doesn't work. (Doesn't look
> like SQL query in any case.)
> A more general question: Education about SQL.
> I have an MS in biostats so I'm not totally
> computer illiterate, but I've never programmed
> anything GUI.
> Thanks for any answers
> Michael Young

SELECT @.@.VERSION
SELECT SERVERPROPERTY('Edition')

The second one is only in SQL2000 only. As for education, you might want to
start with some general books on databases and the SQL language, although
Microsoft's own training material is usually pretty good. You may find some
useful information here:

http://vyaskn.tripod.com/sqlbooks.htm

Simon

ID Creation/ASP/SQL Server

Using SQL Server with ASP for an intranet website.
I'm generating a ID using a user defined function. (getting the Maximum and
adding 1 to get a new ID )
During testing i have got 2 similar ids (example: 31000,31000) for 2 records
when there is concurrent access to a website
here i need to track the ID generated,manipulate and convert into string
format (example: U31000_CTF_FILE)
so im generating it thru function.
is there any other best way to generate & track IDs.
Note: im not using any stored procedures moreover i want to use normal ASP
code only
please help
-dnkHi
You can try somethimg like that
CREATE PROC spNewIds
AS
DECLARE @.new_id INT
BEGIN TRANSACTION
SELECT @.new_id =COALESCE(MAX(Id)+1,0) FROM MyTable WITH (UPDLOCK,HOLDLOCK)
INSERT INTO AnotherTable (colname) VALUES (@.new_id )
COMMIT TRANSACTION
"DNKMCA" <dnk@.msn.com> wrote in message
news:uPeCLiOFGHA.916@.TK2MSFTNGP10.phx.gbl...
> Using SQL Server with ASP for an intranet website.
> I'm generating a ID using a user defined function. (getting the Maximum
> and
> adding 1 to get a new ID )
> During testing i have got 2 similar ids (example: 31000,31000) for 2
> records
> when there is concurrent access to a website
> here i need to track the ID generated,manipulate and convert into string
> format (example: U31000_CTF_FILE)
> so im generating it thru function.
> is there any other best way to generate & track IDs.
> Note: im not using any stored procedures moreover i want to use normal
> ASP
> code only
> please help
> -dnk
>|||Why don't you just have a dummy table with an IDENTITY column?
CREATE TABLE dbo.MyTable(ID INT IDENTITY(1,1))
Now In the ASP code,
set rs = conn.execute("SET NOCOUNT ON; INSERT dbo.MyTable DEFAULT VALUES;
SELECT SCOPE_IDENTITY()")
Response.Write rs(0)
Though I'm not sure I understand the objection to using stored procedures,
or what you mean by "track IDs"...
"DNKMCA" <dnk@.msn.com> wrote in message
news:uPeCLiOFGHA.916@.TK2MSFTNGP10.phx.gbl...
> Using SQL Server with ASP for an intranet website.
> I'm generating a ID using a user defined function. (getting the Maximum
> and
> adding 1 to get a new ID )
> During testing i have got 2 similar ids (example: 31000,31000) for 2
> records
> when there is concurrent access to a website
> here i need to track the ID generated,manipulate and convert into string
> format (example: U31000_CTF_FILE)
> so im generating it thru function.
> is there any other best way to generate & track IDs.
> Note: im not using any stored procedures moreover i want to use normal
> ASP
> code only
> please help
> -dnk
>sql

ID Column has backed down !

hi
honestly, i can't understand
why the pointer has backed down...
in design view, i see the value 147.720
while the last id-key is 147.772
what happens ?
thanks
atte, Hernn
You need to post your DDL so we can better understand the question. Are you
working with the identity property or is this a home-grown id?
--Brian
(Please reply to the newsgroups only.)
"bajopalabra" <bajopalabra@.hotmail.com> wrote in message
news:essjRIIuFHA.204@.TK2MSFTNGP10.phx.gbl...
> hi
> honestly, i can't understand
> why the pointer has backed down...
> in design view, i see the value 147.720
> while the last id-key is 147.772
> what happens ?
> thanks
> --
> atte, Hernn
>