Questions tagged as 'tsql'

2
answers

T-SQL with like sensitive to case

Is it possible to query in SQL Server 2008 with like sensitive? Actually, I'm looking at a column with a list of acronyms, which represent system flags, which are case sensitive. The question is not about the performance of this search, since...
asked by 30.01.2014 / 13:46
1
answer

What's the difference between Cast and Convert?

In a Transact-SQL book (Ramalho Series) it is said: CAST AND CONVERT    Implicitly converts one expression from data types to another.   CAST is a synonym for CONVERT. What do you mean by CAST is synonymous with CONVERT? What is the us...
asked by 21.06.2017 / 13:58
1
answer

Sequential Dynamic T-SQL Pivot

Breaking the head here to create a proc using pivot for this transformation: Is there a possibility? * Using sql server 2008R2 EDIT: CREATE TABLE #Teste5 (name VARCHAR(50),message VARCHAR(50),dtStart VARCHAR(50)) GO...
asked by 06.04.2018 / 22:12
4
answers

How to perform SQL concatenation

I need to concatenate year and month. How could I do that? select cast(year(orderdate) as int) + ' ' + cast(month(OrderDate)as int) as Year_Month From sales.SalesOrderHeader     
asked by 14.08.2017 / 18:15
1
answer

Show alert message without causing an exception

I would like to display an alert message to the user without causing an exception in the procedure. I am using SQL Server. So I can not use RAISERROR , nor PRINT , as it is not shown to the user. Is there a way to display an alert...
asked by 21.11.2016 / 13:45
1
answer

How to do PIVOT from a column, concatenating strings in SQLServer

Hello, I am doing a query in a database to identify all the columns that are primary key 's of the tables of a database and also to identify if they are identity . For this I use the query below: SELECT OBJECT_NAME(C.OBJECT_...
asked by 21.08.2018 / 16:21
1
answer

Best practices when using SqlCommand? Text or StoredProcedure?

I'm wondering which of the following approaches is best? 1 - Add a file *.sql as Resource , then run SqlCommand with CommandType.Text . 2 - Add a Store Procedure to the Database, then run the SqlCommand with CommandT...
asked by 19.01.2015 / 17:27
2
answers

How to get the date of creation of an index in SQL Server?

By SQL Server Management Studio I did not find in the properties of an index its creation date. How can I get the date of creation of a specific index just by name?     
asked by 20.01.2014 / 21:56
1
answer

How to throw custom T-SQL exception?

I have a tigger for CPF validation, and I want to throw an exception if the entered CPF is invalid. About throwing exceptions I've been reading this # But what I want is to throw a new exception, an exception that does not exist in the syst...
asked by 26.06.2016 / 16:30
1
answer

Get the max value inside a while that is inside a cursor

My question is this: I have my cursor for the interaction line by line and inside it I have a while for horizontal interaction. I'm trying to populate a table whose PK does not have identity , using MAX and setting +1 in w...
asked by 25.08.2015 / 20:21