Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 New(ish) to T-SQL ; a few questions.

Author  Topic 

Jaybee from his castle
Yak Posting Veteran

64 Posts

Posted - 2004-03-25 : 10:38:39
Hi all, getting back into DBA work after a couple years helping dad out of manpower shortages (what a sucker!)



I'm pretty rusty at T-SQL, and although I learned the basics for the Admin exam, I rarely had cause to touch it on the job between 99-2002 - and when I did, I had plenty of time to research syntax.

Firstly, what is 'No Count'?

Secondly, here's a syntax question that bothered me for ages. When cutting code for insertion into QA, when must you use apostrophes? This annoyed the heck out of me, as QA often came back with oblique error messages like 'Mistake on Line 23', but didn't say what the mistake was;

Thirdly, is there a nice, easy list of scripts/Stored Procs that I can read to help brush up again?

Thanks all,

JB

TurdSpatulaWarrior
Starting Member

36 Posts

Posted - 2004-03-25 : 10:57:21
When executing a SQL statement, by default SQL returns the the variable @@ROWCOUNT which returns the number of rows affects by the last statement ran. Many people turn this option off by using "SET NOCOUNT ON" so as to save a bit of processing power in their applications.

For inserts, you must surround non-numeric based values with an apostrophe. If there is an apostrophe in the middle of a value you are inserting, replace it with two apostrophes.

This site is filled with examples ranging from beginner to advanced. I'd peruse some of the articles around here, and if you don't find the answers you seek, do a search in the forums or BOL (books online).

Jay
Go to Top of Page

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-03-25 : 11:01:50
Jay

I don't believe the SET NOCOUNT ON is anything to do with saving processing power, it reduces network traffic telling the client how many rows have been processed after each statement.


Raymond
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-03-25 : 11:44:21
Raymond is correct. It's also required when your t-SQL has multiple queries in it and you only want the last query to be returned as a Recorset in ADO 2.6.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

TurdSpatulaWarrior
Starting Member

36 Posts

Posted - 2004-03-25 : 12:20:33
O ok; I'm retarded. I knew it was good for making things faster, just had the wrong reason. Apologies.
Go to Top of Page

TurdSpatulaWarrior
Starting Member

36 Posts

Posted - 2004-03-25 : 12:23:22
O yeah, and here's another good tip: never take database advice from a web developer :-)
Go to Top of Page

Jaybee from his castle
Yak Posting Veteran

64 Posts

Posted - 2004-03-25 : 12:24:15
quote:
Originally posted by TurdSpatulaWarrior

For inserts, you must surround non-numeric based values with an apostrophe. If there is an apostrophe in the middle of a value you are inserting, replace it with two apostrophes.


Thanks, but is that also true for Selects, Deletes etc?


JB.
Go to Top of Page
   

- Advertisement -