Jayce Ooi’s Paradise

Photography, programming, technology, finance, anything =)
Subscribe to Jayce Ooi's Paradise feeds

OBJECT_ID (Transact-SQL)

OBJECT_ID (Transact-SQL) is database object identification number of a schema-scoped object.

Example, it will drop table test if the table test already exist in the database.

IF OBJECT_ID (N’dbo.test’, N’U') IS NOT NULL
DROP TABLE dbo.test;
GO

SET QUOTED_IDENTIFIER ON / OFF (Transact-SQL)

When SET QUOTED_IDENTIFIER ON, identifiers can be delimited by double quotation ” marks, and literals must be delimited by single quotation ‘ marks. However, when SET QUOTED_IDENTIFIER OFF, identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers. Hmm… So what this mean?

For example,

SET QUOTED_IDENTIFIER OFF
GO

– You cannot use reserved keyword, it will fail
CREATE TABLE “select” (”identity” INT IDENTITY NOT NULL, “order” INT NOT NULL)
GO

SET QUOTED_IDENTIFIER ON
GO

– When is ON, you can use reserved keyword. It will pass.
CREATE TABLE “select” (”identity” INT IDENTITY NOT NULL, “order” INT NOT NULL)
GO

Another example,

SET QUOTED_IDENTIFIER OFF
GO

– Literal strings can be in single or double quotation marks.
INSERT INTO dbo.Test VALUES (1, “‘Text in single quotes’”)
INSERT INTO dbo.Test VALUES (2, ‘”Text in double quotes”‘)

SET ANSI_WARNINGS ON / OFF (Transact-SQL)

When SET ANSI_WARNINGS ON, warning message will be returned. On the other hand, SET ANSI_WARNINGS OFF will turn off the warning message.

Convert double to int - C# source code

Hope this will help. :)

double i = 7.88;
int x = Convert.ToInt32( i );

Replace string - C# source code

I need to replace some of the words in the sentence. But how am I going to do so? Let’s say, I have this sentence as example.

I love to eat durian very much.

I want to replace the word “durian” with “apple”. Just follow below C# source code to replace it.

String sentence = “I love to eat durian very much.”;
sentence = sentence.Replace(”durian”, “apple”);

You will get the output like this…

I love to eat apple very much.

Based on the example above, just key in 2 parameters in String.Replace(”old value“, “new value“). The “new value” will replace “old value”.
Enjoy coding…

« Older Entries  Newer Entries »

Page 5 of 10« First...«34567»...Last »

Sponsored links

Archives

Chat Chat Chat...




RM210 (US$63) Cash Giveaway

Make Your Own Gifts Here


Community links

edensitebar.jpg
Support WWF-Malaysia

Please support me...

Top Commentators