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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Help on TSQL Query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cnubabudwh
Starting Member

India
1 Posts

Posted - 03/20/2013 :  04:55:31  Show Profile  Reply with Quote
In the query below TextColumn contains string data, NullColumn is always null and TimeColumn contains value of data type time(0). What is the output.
Hint: CONCAT is a new SQL2012 function.
SELECT * FROM Table1
WHERE CONCAT(TextColumn, NullColumn, TimeColumn) > ''

A data conversion error will occur.
A recordset of all columns and all records will be returned.
An empty recordset will be returned.
A syntax error will occur.

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 03/20/2013 :  05:38:26  Show Profile  Reply with Quote
I think this is the answer........
A recordset of all columns and all records will be returned.

Support Documents are:
http://raresql.com/tag/sql-server-2012-concat/
http://www.sql-server-helper.com/sql-server-2012/sql-server-2012-new-string-functions.aspx

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/20/2013 :  11:55:54  Show Profile  Reply with Quote
why not test it with an illustration


declare @table table
(
Textcol text,
NullCol varchar(50),
timecol time
)

insert @table
values('wefdwef3f3f3ffwefw	f',NULL,'18:02')
SELECT * FROM @table
WHERE CONCAT(TextCol, NullCol, TimeCol) > ''


output
-----------------------------------------------
Textcol	                       NullCol	timecol
------------------------------------------------
wefdwef3f3f3ffwefw	f	NULL	18:02:00.0000000



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 03/21/2013 :  00:03:01  Show Profile  Reply with Quote
Hi visakh,

I don't have MSSQL 2012 version... I have provided answer as per documents
Go to Top of Page

UnemployedInOz
Yak Posting Veteran

Australia
54 Posts

Posted - 03/21/2013 :  01:55:13  Show Profile  Reply with Quote
Create table #Table1
(TextColumn varchar(10),
NullColumn varchar(10),
TimeColumn time)

Insert into #Table1 select 'ABC',null,CURRENT_TIMESTAMP

SELECT CONCAT(TextColumn, NullColumn, TimeColumn) FROM #Table1

-- Result
ABC16:53:28.1430000
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 03/21/2013 :  02:07:22  Show Profile  Reply with Quote
quote:
Originally posted by UnemployedInOz

Create table #Table1
(TextColumn varchar(10),
NullColumn varchar(10),
TimeColumn time)

Insert into #Table1 select 'ABC',null,CURRENT_TIMESTAMP

SELECT CONCAT(TextColumn, NullColumn, TimeColumn) FROM #Table1

-- Result
ABC16:53:28.1430000



We have already provided answer....
In your script, put TIME(0) instead of type TIME... (OP asked for timeColumn as TIME(0) type)..
Any way the answer is A recordset of all columns and all records will be returned.

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/21/2013 :  02:18:46  Show Profile  Reply with Quote
quote:
Originally posted by bandi

Hi visakh,

I don't have MSSQL 2012 version... I have provided answer as per documents


That was not for you but for OP



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000