Definition

Fast Guide: SQL Server 2000 commands

Here are ten SQL server 2000 commands you need to know!

 

1. This allows you to read ten rows from a table.

select TOP 10 * from TABLE_NAME

2. This is used to show the text for a given stored procedure.

EXECUTE sp_helptext PROCEDURE_NAME

3. This is used to ensure a null field is returned as zero.

select ISNULL(FIELD_NAME, 0) from TABLE_NAME

4. This is used to show all object names in the current database matching a pattern.

select * from sysobjects where name LIKE '%PATTERN%'

5. This is used to show the table definition.

EXECUTE sp_help TABLE_NAME

6. This is used to show all DTS packages that match a pattern.

select distinct name from msdb.dbo.sysobjects where name LIKE '%PATTERN%'

7. This is used to show all constraints for table names in the current database matching a pattern.

 select * from INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE where TABLE_NAME LIKE '%PATTERN%'

8. This is used to run UPDATE STATISTICS against all user-defined tables in the current database.

EXEC sp_updatestats

9. This is used to show all stored procedures in the current database that match a pattern.

select * from sysobjects where xtype = 'P' and name LIKE '%PATTERN%'

10. This is used to ensure an empty string is returned as null.

select NULLIF(FIELD_NAME, '') from TABLE_NAME

 

 

This was last updated in June 2006
Posted by: Margaret Rouse

Email Alerts

Register now to receive SearchSQLServer.com-related news, tips and more, delivered to your inbox.
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

More News and Tutorials

Do you have something to add to this definition? Let us know.

Send your comments to techterms@whatis.com

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: