Questions tagged as 'sql-server'

3
answers

Convert VARCHAR to DATE in a SELECT

I have a table whose record has a date, but this date is saved as VARCHAR , I was told that I could convert it to DATE in SELECT . This is what I have: SELECT * FROM tabla WHERE CONVERT (date(15), fecha, 103) = '1/01/2017';...
asked by 15.11.2017 / 16:22
3
answers

Split_String in SQL and use its values

I have a very simple operation, but I do not know how to proceed. In a Stored Procedure I get a string full of Id's separated by commas, so I need to separate that string and use its content within a INSERT . But I do not know how to use...
asked by 31.08.2018 / 01:28
2
answers

SQL query between two SQL SERVER tables

I have two tables (tb_Product_M and tb_Product_Product) that presents a recursion, where a Product can have several Product children. In the table tb_Product_Product contains the data of the parent_Product_id that Products children has this. I n...
asked by 31.08.2018 / 21:16
2
answers

Can I form a WHERE in a variable of @?

A question, Can I put the condition (WHERE) in a variable? where does it contain all the conditions and use it at the end of my SP? If it is possible, how could it be done? something like SELECT * FROM TABLA WHERE fecha = @condiciones; W...
asked by 06.08.2018 / 22:11
1
answer

SQL + C # Variable value Null or NULL?

Good morning. I have an ASP.NET C # application and in a WebForm I must insert data in a table. For this, create a stored procedure and you can insert null data: CREATE PROCEDURE [Insertar_Tabla] @var1 INT=NULL, @var2 VARCHAR(10)=NULL...
asked by 30.06.2017 / 20:30
2
answers

Group and have the data with the autoincremento mayor- SQL

I need to search in a database like this, where "id" is the variable with autoincrement: id device 6 1 5 1 4 2 3 2 2 1 1 1 I need to sort by "device" but it gave me when "id" is minimal, I need to group w...
asked by 24.10.2018 / 02:57
3
answers

Take sql data and mark it as active or current

I want to do this in php maybe I can not explain myself well so if you need to modify it do not worry I can do it quickly since I feel in my pc I have a table with only 2 variables (ACTIVE) and (NOT ACTIVE) $sql = mssql("select estado from...
asked by 26.01.2017 / 12:52
1
answer

Update data with spaces in sql server

I have a database, with a couple of tables in which I have stored many records that have been brought from another database. My big drawback is that the data has passed with spaces, before the actual data, it seems that sql server will take t...
asked by 11.04.2018 / 23:45
2
answers

Put a variable as a title in an sql server query

I want you to show me a variable variable in the header. When I do this: declare @dato char(6) declare @sql varchar(800) set @dato='201601' select @sql='select @dato as '+ @dato exec(@sql) I get this error:    Msg 137, Level 15, State...
asked by 14.09.2016 / 17:52
2
answers

Show a field considering 10% of another column using SQL Server

I would like you to help me with this query, I want the costs that are greater than 1000 to show me in another column increased to 10%. At the moment I only have: SELECT * FROM tarifa The result is the following: I hope you can...
asked by 22.03.2017 / 23:00