I need help understanding how to create proper indexing on a table for fast range selects. I have a table with the following columns: Column — Type frameidx — int u — int v — int x — float(53) y — float(53) z — float(53) None of these columns is unique. There are to be approximately 30 million records in
Tag: sql-server-2012
SQL Server: Best way to concatenate multiple columns?
I am trying to concatenate multiple columns in a query in SQL Server 11.00.3393. I tried the new function CONCAT() but it’s not working when I use more than two columns. So I wonder if that’s the best way to solve the problem: I can’t use COLUMN1 + COLUMN2 because of NULL values. EDIT If I try SELECT CONCAT(‘1′,’2′,’3’) AS
Query JSON inside SQL Server 2012 column
I have a column inside my SQL Server 2012 table which contains following Json data. Now I want to use this column data in my query like Is there a way to query JSON data in SQL Server 2012? Answer Honestly, this is a terrible architecture for storing the data, and can result in some serious performance issues. If you
Open and Close Cursors Inside or Outside a Transaction and How to Close a Cursor if a Transaction Fails
I am writing a stored procedure in SQL Server 2012 that uses a cursor for reading and a transaction inside a TRY CATCH block. Basically, my questions are as follows: Should I declare my cursor inside the TRY CATCH block? If yes, should I declare the cursor before or after the BEGIN TRANSACTION statement? Should I open the cursor before
How to Display student attendance in gridview using SQL and Gridview
I am using SQL Server 2012 and VS 2012 C# I have designed database table Roll_No, Attend_Date, Attend_Status while storing data i store like this But I have to show in grid-view like this Can you Help me please… How can I achieve this result.. Answer You can do this by listing each date as column name while doing PIVOT
TRY/CATCH block vs SQL checks
Shortly, I am wondering which of the following is the better practice: to encapsulate my code in TRY/CATCH block and display the error message to write own checks and display custom error messages As I have read the TRY/CATCH block is not handling all types of errors. In my situation this is not an issue. I am building dynamic SQL
SELECT DISTINCT values and INSERT INTO table
I want to take a column with values that repeat multiple times and get that value only once and store it for later use, but at the same time I would like to get another value in the same row as that distinct column. A, B, C represent three columns. Ignore C for now. My question is: How can I
Sql server – recursive delete
I’m trying to delete user’s data and all it’s related data that is located in different tables. All the tables have Foreign Keys but without cascade delete. I investigated some options: Enable cascade delete on all FK, delete and remove the cascade delete. Delete from bottom UP, loop up for all the leaves delete and repeat this operation till Root.
Joining two tables with specific columns
I am new to SQL, I know this is really basic but I really do not know how to do it! I am joining two tables, each tables lets say has 5 columns, joining them will give me 10 columns in total which I …
Convert Date format into DD/MMM/YYYY format in SQL Server
I have a query in SQL, I have to get a date in a format of dd/mm/yy Example: 25/jun/2013. How can I convert it for SQL server? Answer I’m not sure there is an exact match for the format you want. But you can get close with convert() and style 106. Then, replace the spaces: