MERGE between 2 tables, one table with 10million rows

TableA match / Keyword 0 Stackoverflow 1 Youtube 1 Google 0 Yandex 1 Twitter 0 Facebook 0 Teacher Totally 10million rows in TableA There is Clustered index at Keyword column TableB match / word 1 You 1 Go 1 Twit 0 Home 0 Car 0 Pencil 0 Money 0 Weather 0 Her Totally 500 rows […]

How to get the Identity values in SQL BULK COPY?

I have to get the IDENTITY values from a table after SQLBULKCOPY to the same table. The volume of data could be thousands of records. Can someone help me out on this ?

Import multiple delimited text files into a SQL Server database and automatically create tables

I have multiple delimited text files (e.g. .csv files), each containing columns, rows and a header. I want to import all of these input files into SQL Server with as much ease as possible. Specifically, I want to create the output tables into which I will import these files on the fly. Some of these […]

select other column which having min value in subquery

Is there any way to select other column which having MIN value in subquery? In my subquery, i produce lists of value. Then how to get the time that I produce that value here is my code : Select A, (select Time from result where value = ??MIN VALUE), MIN (value) from ( //subquery ) […]

How to export selective columns of multiple tables from SQL Server to one csv file?

In SQL Server (or SQL Server Data Tools) is there a way to export selective columns of multiple tables from SQL Server to one csv file? The database is a Linked Server object connected in SQL Server connected ODBC.

Is there a way to retrieve inserted identity as well as some values from the query in an INSERT SELECT?

I have a situation in which I need to insert some values from a query into a table that has an identity PK. For some of the records, I need also to insert values in another table which has a 1-to-1 (partial) relationship: CREATE TABLE A ( Id int identity primary key clustered, Somevalue varchar(100), […]

how to substring an empty phrase in sql?

I have a link and I want to substring it into many pieces to get numbers example:- &OR=-12&MR=24560&MM=20&Mx=110&EOW=1&OW=50&OV=12&CV=-1 I want the -12 , 24560 , 20 , … etc. and I did it using this code DECLARE @strprog AS NVARCHAR(MAX)–,@strLM AS NVARCHAR(20),@strLOW AS NVARCHAR(20),@strLOR AS NVARCHAR(20),@strLCR AS NVARCHAR(20), DECLARE @OR AS SMALLINT, @MR AS SMALLINT, […]

Aggregate function with image data type

What is the best way to perform an aggregate function on an image data type? For example, where binImage is image data type, and I want to return either binImage or null: max( case when somechar = ‘A’ and anotherchar = ‘B’ then binImage else null end ) as result … will not work, because […]

Seeding my DB with Entity Framework DateTimes

I am using Code First Workflow with Entity Framework 6.1.3 and I am trying to seed my database with some data by adding a migration like so: public partial class SeedDatabaseWithBusinesses : DbMigration { public override void Up() { Sql(“INSERT INTO Businesses (GooglePlaceId, Name, CurrentMenu, LastUpdated)” + ” VALUES (‘googlePlaceIdHere’, ‘Examples Businesses Name’, ‘Fish and […]

Add “- All” as default parameter in my SSRS binary parameter

I have some parameter in a SSRS. I add a “- All” parameter as default value in all of them. For one parameter, a binary one, this cause this error : Syntax error converting the nvarchar value ‘- All’ to a column of data type bit. Here is my Query : SELECT mValue.value AS V […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.