.NET Programming With Me

TSQL Questions

1. What is the output of both the queries on a database?
CREATE TABLE dbo.Zip_code
(
  id    VARCHAR(10) NULL,
  Descr VARCHAR(max) NULL
)
GO

INSERT INTO dbo.Zip_code VALUES('1111', 'AAAA')
GO
INSERT INTO dbo.Zip_code VALUES('2222', 'bbbb')
GO
INSERT INTO dbo.Zip_code VALUES('aaaa', 'bbbb')
GO

SELECT count(*) FROM Zip_code WHERE id = '1111'
SELECT count(*) FROM Zip_code WHERE id = 1111

Options: a) 1,1     b) 1, error    c) error, error

2. What is the output of the SELECT query?
CREATE TABLE test
(
  col1 INT,
  col2 CHAR(2)
)
GO
INSERT INTO test VALUES(1,'AB')
INSERT INTO test VALUES(2,'Ab')
INSERT INTO test VALUES(3,'aB')
INSERT INTO test VALUES(4,'ab')
INSERT INTO test VALUES(5,'XY')
INSERT INTO test VALUES(6,'xy')
GO
SELECT COUNT(*) FROM test WHERE col2 in ('AB', 'aB', 'xy')

Options: a) 3     b) 6    c) None

2 comments: