Click here to Skip to main content
15,892,809 members
Everything / Database Development / SQL Server / SQL Server 2012

SQL Server 2012

SQL-Server-2012

Great Reads

by AshishShukla6
This tip describes step by step implementation of executing stored procedure having user-defined table type as a parameter in entity framework using EntityFrameworkExtras package.
by Sarathi Balakrishnan
Reset SQL server SA (System Admin) Password when you have lost all possible ways to connect to SQL server and your server has only Windows authentication disabled. You should have Windows administrator permission to do this.
by AhsanAhmed
A brief introduction on how to use FOR XML clause in AUTO mode in Microsoft SQL Server to return data in XML format
by DiponRoy
How to do string split and join in SQL Server

Latest Articles

by DiponRoy
A utility query to find table generations in SQL Server relational database
by DiponRoy
How to do string split and join in SQL Server
by Micah Nikkel
SQL script that dynamically generates the DR scripts for failing over/back all Log Shipped databases. While it makes even a single database failover/failback a more streamlined process, it's most helpful for servers with multiple databases, such as SharePoint, consolidated SQL Servers, etc.
by Luca Astolfi
User defined procedure for make an HTML table from T-SQL Select statment

All Articles

Sort by Title

SQL Server 2012 

29 Sep 2020 by SandeepKumar.K
Hi, I have deployed SSIS package on SQL SERVER 2019 Standard Edition(Version : 15.0.200) and package is using CDC control Flow task. Now, when I execute the package it's getting below error. Quote: 'cdc control task' cannot run on the installed...
29 Sep 2020 by Richard Deeming
This is a problem with the Microsoft documentation - the feature requires Enterprise edition, but this is not mentioned in the documentation. Even if you don't believe the error message for some reason, other sources will confirm that CDC only...
8 Jan 2015 by shaliniraji
Hi everyone,I've created 1 windows app in that app i've created Registration form including image fields.After filling all the details in that form when i click on save button i'm runtime error(Failed to convert parameter value from a Bitmap to a Byte[])..Can anyone tell me how to resolve...
7 Jan 2015 by OriginalGriff
Um...The only thing you use the array of bytes for is to get it's length:byte[] photo = GetPhoto(imageloc);... SqlParameter p17 = new SqlParameter("@Vehicle_Pic",SqlDbType.Image,photo. Length);SqlParameter p18 = new SqlParameter("@Customer_Pic ", SqlDbType.Image,...
1 Jul 2015 by MacParekh
I have uploaded site on Sever. Two site one of them hosted with .NET 4.0 framework. and second in .NET 2.0 framework. 4.0 framework site working properly. But 2.0 framework site unable to load CSS, javascripts and images. It is giving 500 error. As well as reference error "WebForm_AutoFocus...
17 Sep 2015 by Member 10010145
Hi All,I am going to build one application using .net.In this application I am using SQL SERVER. Application should give quick response when there are 1 million insert operations from 1 million users at same time.Is there any way to make this operation faster in SQL SERVER?Please...
17 Sep 2015 by OriginalGriff
You are going to need to set up (or rent access to) a Database Server Farm.[^]
13 Jul 2016 by Engr Nouman
I want to avoid duplication of data suppose i have a table name Schema_tbl that holds 2 coloums Schema_tbl columns are : tblNames | primaryKeysColdata: tblCustomer | cmpid tblCustomer | ...
13 Jul 2016 by Suvendu Shekhar Giri
Try-ALTER TABLE Schema_tbl ADD CONSTRAINT pk_myConstraint PRIMARY KEY (tblNames,primaryKeysCol)Hope, it helps :)
5 May 2015 by Christopher Fernandes
I have a stored procedure in which i am inserting value in table t1 and after inserting values in table t1 updating a column c1 in table t1.And am using two integer scalar variable @v1 and @v2 to get count of rows affected by using @@ROWCOUNT for both scalar variables.It works fine for...
6 May 2015 by vivvicks
Dear Chris,your condition might be failed on this condition Last_Updated_By = @Created_By, Last_Updated_DateTime = GETDATE()
6 May 2015 by CHill60
Actual solution confirmed by OP - there was no data matching where Ref_DeskTimeCurrentVersion_ID @Ref_DeskTimeCurrentVersion_IDOnce data was entered the problem was resolved.
15 Jun 2015 by Bhanuchandar Challa
Hello All,I am trying to find how much storage space is used by my MS Sql Server's database instance and how much increasing day-by-day.Below is the query used to get for Oracle DB instance:SELECT SUM(bytes)/1024/1024/1024 SCHEMA_SIZE_GB FROM USER_SEGMENTS; How can I find the...
15 Jun 2015 by Andy Lanng
It is a requirement that this be done via a query?SELECT DB_NAME(database_id) AS DatabaseName,Name AS Logical_Name,Physical_Name, (size*8)/1024 SizeMBFROM sys.master_filesWHERE DB_NAME(database_id) = 'AdventureWorks'GOIt is very easy to find this info via the management...
23 Mar 2016 by Luiey Ichigo
Hi all,I have connect both SQL Server(Source) on my notebook and Azure SQL(Target) using Visual Studio Pro 2015.How to do automation for running schema for some interval e.g every one hour check for comparison? This function will be placed to somewhere else without any IT guy to update...
6 Jun 2016 by DimitriStPi
Hi, I have a project that brings me to work on SQL Server. A functionality is the next one:On a serial number insertion, the SQL Server has to return N number of MAC addresses. Those MAC addresses values are depending on the serial number value. For a given serial number the...
6 Jun 2016 by Wendelius
Based on the title of your question ([Sql] highly customized auto generated column) I believe that you have a wrong approach. If you need a set of MAC addresses with single call you cannot bind the logic into a single row. You need to create for example a function or stored procedure to create...
16 Jul 2015 by Math08avan
A simple example for CRUD actions using WCF service in ASP.NET
23 Dec 2015 by Md. Marufuzzaman
A simple tip/trick to get rows on n’th maximum number from a table
18 Dec 2015 by Md. Marufuzzaman
A simple example of Microsoft SQL Server Pad String
6 Aug 2015 by Furqan Sehgal
Hi,My client is using my SQL Sever application, sever installed on one of his local computers, dbs are being accessed using connectionString="Data Source=Office1-MAIN-PC\EziBilling;Initial Catalog=dbBilling;User ID=sa"By now everything is fine, now he demands to access the databases...
7 Aug 2015 by Vibhav Ramcharan
Hi,Configure Server instance via SQL Server Configuration Manager to allow TCP/IP Protocols.SQL Server Network Configuration > Protocol for [InstanceName] > EnableYou could use a Dynamic DNS Service to resolve the IP of the server.Ensure you open up port 1433 on your Server...
6 Oct 2015 by TheAbominable
Help! We are in the process of creating a web server in the DMZ. Let's call it 'X' Web Server. We have a website in the web server which uses integrated security. The website utilizes an Application Pool called 'AppPoolX'AppPoolX uses a local web server account for the Application Pool...
7 Oct 2015 by Abhishek Pant
Hi,I have two table valued functions as T1 and T2and executing this I get T1 data as ParameterID Parametername ParameterDoc 1 French French Data 2 German German Data 3 Polish Polish Data ...
7 Oct 2015 by Ankur_Garg
The above query would simply give a Cartesian product of the 2 tables. That means it would print 20 rows(4*5). To get the expected data, you should have a column matching in both the tables which isn't the case here. Try adding another table which contains the following information:Table...
30 Apr 2020 by Member 13779417
The following stored procedure works fine but I need to add another condition in relation to another table called tblItems. I require tblAccounts.accountID to join with tblItems.AccountID so I can check if tblItems.fileID > 0 for every accountID...
29 Apr 2020 by Eek Ten Bears
This is a comment and suggestion rather than a solution A WHERE EXISTS is not the best way for you here, it is overly complex for what you need. As a result it will be detrimental to the performance of the query. Also I note you include the...
30 Apr 2020 by Eek Ten Bears
ah ok I understand what you are after now. Wood for the trees problem. Don't need to do much to make your code work at all. I still don't much like using EXISTS but it might be appropriate here and will work if you remove this: INNER JOIN...
28 Oct 2014 by Member 11186502
I am creating a transport website where i have to create branches (i.e london ,delhi) so when i assign a person that branch he will open its account into that branch.One thing more that i have created the database but Dataset should be assigned to every Branch i.e. that every branch will have...
28 Oct 2014 by Sergey Alexandrovich Kryukov
Please see my comments to the question. This reading can help you:http://msdn.microsoft.com/en-us/library/eeyk640h%28v=vs.100%29.aspx[^],ASP.NET authentication and authorization[^].One advice: don't try to save time and first make the decision on some particular solution and then learn...
8 May 2014 by SunilKumarMahanta
Adding integer column to large table SQL Server 2012 taking more time than character type. During that time database getting hang. Why is the difference. My database size is more than 200 GB and the table size is more than 10GB, number of record in that table is more than 2242607.Adding...
9 May 2014 by Torakami
First of all your database is so larger in size . shrink your database file and log file to reduce the size . try not store all details in log files. To maintain log file is not a great idea , retrieve data from log files is tedious job and the best practice is to take daily backup.
9 May 2014 by CHill60
Whenever we did schema changes against our tables in my previous employ, we ran scripts to drop all indexes first. You might need to check to see if you have any constraints on the table also. This link might be useful for that sqlservercentral[^] (just realised you have to register on the site...
18 Jun 2014 by phil.o
Ok, I'm so late on this one.The difference could be due to the physical layout of data in ?df files.It's just a guess, though; I'm only trying to understand what could eventually explain such a behaviour.Imagine integral types are stored preferentially at the beginning of the file,...
20 Dec 2012 by thomasriley
Hi everyone,I'm creating a User and Login for one of my databases below:USE HWProjectViewGOIF NOT EXISTS(SELECT * FROM sys.sql_logins WHERE name=N'HWProjectViewUser')BEGIN CREATE LOGIN [HWProjectViewUser] WITH PASSWORD='My_P4SsW0Rd-H3R3'ENDIF NOT EXISTS(SELECT * FROM...
20 Dec 2012 by DaveP62
You can see the script the interface uses by: 1. Add permissions in the interface (but do not click the OK button) 2. Click the script button at the top of the interface 3. Choose "Script Action to New Query Window"A query window will open with the script you need to add the...
17 Feb 2017 by Sumit-HopeForBest
In a grid capturing integer value for two different dates using hidden field calling value in grid please guide how to save aging value in SQL table..aspx code is
17 Feb 2017 by NightWizzard
Why not use a computed column at the SQL table instead of calculating it in your app and save it to the database? With a computed column the age is always up to date for each record depending on the values stored within.
22 Mar 2015 by Aby Mammen Mathew
IoT devices needs the capability to augment the environment around them, even when sensors utilized by them break down
8 Oct 2016 by Member 12782887
Is there any feature in sql server 2012 or in any version , wherein I can track all DB activities(DDL and DML) and others in one single query with who has modified and from where and when?I need hostname or IP adddress as well.What I have tried:I tried below features which has some...
8 Oct 2016 by Suvendu Shekhar Giri
Although I haven't used it much, i think you can start your research with SQL Server Profiler-https://msdn.microsoft.com/en-us/library/ms181091.aspx[^]If you need much more details than all these then I think you need to look for third party tool. Hope, it helps :)
8 Oct 2016 by Member 12782887
I used trace files(which is profiler only but query not GUI) to get data but its not tracking select, insert and delete statements.I know GUI gives you everything but i dont want to run GUI.
24 Feb 2015 by khurram ali lashari
I wrote a data migration script in which I am checking if the previous data migration is in process then close all db connections this mean change the database mode which is MULTI_USER mode to RESTRICTED_USER mode by donig so my database will go on restricted mode and only autherised connection...
24 Feb 2015 by Wendelius
I take it you're running this in SSMS as a whole. If that's the case it is interpreted as a single batch and a batch has restrictions.To overcome such situation either run the script in smaller parts or add GO[^] statements between separate operations.
24 Feb 2015 by Sergey Alexandrovich Kryukov
Just an idea on this limitation of SQL:This is a declarative language, which is the opposite to imperative. It does not provide a sequence of any instructions to be carried out. When you try to execute a whole "batch" in a multi-statement transaction, you are not really saying: "alter the...
3 Mar 2015 by Sam 9100
My winform has multiple dtp's, here is 1 example:private void btnSave_Click(object sender, EventArgs e){ //DateTime datetimePicker1 = dtpOpened.Value; dtpOpened.Value = DateTime.Today;}BLL layer:public DateTime OpenedDate { get; set; }private MainCaseBL(DataRow dr) :...
23 Feb 2015 by manak chand
The save code is correct.. Please let me know code for retrieving the database record.. which contains OpenedDate field.
3 Mar 2015 by Sam 9100
added instance of my BL class to complete dtp syntax. DTP value saves correctly now. Thank you.
31 Mar 2015 by Sam 9100
I was not using the class instance for my datetime picker. I only had a basic dtp.date that was not binding to my BLL objects.
30 Mar 2015 by syna syna
The SqlWorkflowInstanceStore lock does not exist in the database. This could have occurred because the SQL Server is busy or because the connection was temporarily lost.
7 Nov 2015 by Sujeet Bhujbal
Angular js with ASP.NET MVC is more popular now days and for beginners, I will tell you what is angular js and show you a practical example of ASP.NET MVC for inserting, deleting and displaying data using angular js.
1 Apr 2014 by formlesstree4
26 Aug 2015 by nithyananthams
Different options to get Identity from SQL Server and how OUTPUT clause helped me to get the accurate Identity value compare with other options.
11 May 2015 by MedZi2010
Create a basic SSIS Package to enter the files provided in “ETL_Diagram Section Files” to anew Database called Curriculum. The SQL Script will be executed within SSIS in a SQL Task (The script may be too big to use in a SQL Task. In that case, find another alternative such as putting...
12 Nov 2017 by Member 10230348
I'm facing issue in crystal report does not render on iis 6 plz help me asap Thanks What I have tried: it runs on my local server not on iis
12 Nov 2017 by an0ther1
As suggested above, you need to install the Crystal Reports runtime components on your Web Server. Crystal reports for Visual Studio downloads[^] Additionally, ensure you do not have the Crystal references set to Copy Local in your Project. If you do you will experience issues when you deploy...
2 Jun 2016 by Schatak
I have a code in JS which is pushing value to a comma separated string if that value do not exist in the list.I want the similar thing into SQL Server also.What I have tried:I am able to make comma separated list into column with values, i am converting list into a temp table and...
2 Jun 2016 by OriginalGriff
It's generally a bad idea to store comma separated lists in SQL at all, yopu woudl probably be better off with a second table and a foreign key.But...UPDATE MyTable SET MyColumn = MyColumn + ',' + 'My new item' WHERE MyIDColumn=MyIDValueTakign one back out again is a much, much harder...
14 Mar 2015 by Gaurav_Chaudhary
This tip is a brief introduction to Apply operator in SQL server
22 Jun 2015 by Terence Wallace
The primary purpose of this article is to provide quality sample source code for VB.NET developers interested in building data-centric applications using the .NET Framework.
27 Dec 2015 by Member 12168418
Hi,I am getting below error can any one help me to find out root causeAROutput.0 - ERROR (version 4.1.0, build 1 from 2013-10-16 15.35.49) : Error in BULK ENTRY Transaction : ERROR (552): The SQL database operation failed.; The certificate, asymmetric key, or private key data is invalid....
28 Dec 2015 by ZurdoDev
There are numerous issues that can cause this. What you need to do is troubleshoot it by searching for the error "The certificate, asymmetric key, or private key data is invalid." There are many google results with various things to try.
27 Feb 2018 by webmail123
I am trying to copy the database from SQL Server 2016 to SQL Server 2012. I am getting the version compatibility error. What I have tried: I even tried the command: ALTER DATABASE VJ_DATABASE SET COMPATIBILITY_LEVEL = 110; GO But still I am getting same error. Can anyone please help me?
27 Feb 2018 by OriginalGriff
You can't: it's a different format database, and 2012 doesn't want to risk damaging the database so it can't be opened by the higher version. You can back it up and try restoring it into 2012 as a copy, but you can;t directly use the later version file on an earlier version app.
17 Aug 2015 by DataBytzAI
Method for implementing an audit-trail
23 Sep 2014 by SatyLepide
By analyzing log-in attempts on SQL server, admins can build the complete picture out of the sequence of events that led to compliance failure or unauthorized access.
8 Aug 2015 by Harsh Aggarwal - India
It's about making back up of database in SQL server 2008 and above you can get rid of making bak file manually.
16 Apr 2014 by syed shanu
Chk like this but you need to change your table data type ,why did you used int data type .its better to use nvarchar or char.Declare @code intDeclare @MaxValue nvarchar(max)Declare @LastValue int Declare @strGUID int select @MaxValue = max(RealEstateNumber) from...
12 Oct 2015 by Sathish km
I need result like this: ChNo====|=====Row Column 11 | 10 12 | 14 13 | 16 15 | 18 17 | 19 20 | 21 Row Column =>Will Generate Num based on ChNo Column (exists or not)if not exists(select * from TableNameA...
12 Oct 2015 by CHill60
What you appear to be trying to do is "find a gap in a sequence" using SQL.If I replicate your data as create table temp( ChNo int)insert into temp values (11),(12),(13),(15), (17),(20)The following query will return 14SELECT TOP 1 ChNo + 1FROM temp moWHERE NOT...
13 Aug 2014 by RupeshSharmakol
I am facing problem with asp.net c#. I have one crore file of csv file. When I try to bulk upload all record in a Sql Table. But while uploading data bulk upload after 2 min automatically logout. I increase timeout of application in webconfig but problem remain. Please help me urget.
13 Aug 2014 by DineshMaind
Are you creating new folder at time of file upload? If yes try to upload file in existing folder. Normally this may happen due to change in directory system.
13 Aug 2014 by Gupta Poonam
There are several reasons for session getting expired before specified timeout value.you can check it Here
17 May 2015 by Keymayker
My problem is auto populating Table. I have table with 1000 record in it, but for testing purpose, i need to insert more data. ID | PersonID | Date | Time | Sum | TypeID | PlaceID | StatusIDSo i need to populate the database with 10000 records where the date is between 1/3/2015 and...
17 May 2015 by OriginalGriff
Start here: http://it.toolbox.com/blogs/db2luw/how-to-easily-populate-a-table-with-random-data-7888[^]
21 Aug 2016 by Mizanur Rahman
Hello AllWhen I am going to deploy my database (sql Server 2012) there showing an Error A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that...
20 Aug 2016 by Member 4281397
You need to create SQL database in Azure itself then you can find the server name and server full name. You need to enter the server full name at the time of deployment. Please check and let me know if you have any issues.
20 Aug 2016 by Member 4281397
Did you use Full Server name(*.database.windows.net)?
21 Aug 2016 by Member 4281397
Can you please send me screen shot of steps you are doing? Also check if you can access the database through Azure itself?
12 Feb 2013 by rpm3d
hi every body sup??!i have database with sql 2008i wanna create a strode procedure or everything you think is better forbackup from my database and save that in other driveshow can i do this??
12 Feb 2013 by arindamrudra
1. First write all your procedures in your database.2. Take a backup.3. Restore the backup in your database server.Pictorial description you can find from the below link:http://kb.eukhost.com/backup-and-restore-ms-sql-server-2008-database/[^]- Arindam
12 Feb 2013 by Anurag Sinha V
Hi,Include the below 2 scripts in your stored procedure and it will do the trick..it will take a backup and will restore it too.BACKUP DATABASE [ReportServer] TO DISK = N'H:\Backup\ReportServer.bak' WITH NOFORMAT, NOINIT, NAME = N'ReportServer-Full Database Backup', SKIP, NOREWIND,...
1 Oct 2014 by NaibedyaKar
How to check the query locking the table and to unlock it
2 Sep 2013 by Member 10112611
I'm using the following command in sql 2012 for copy varbinary data to excel filedeclare @SQLcommand varchar(8000)set @SQLcommand = 'bcp "SELECT file_stream FROM XYZ.DBO.XYZFileTable where name=''fdd''" queryout "d:\test.xlsx" -S sql4\MSSQLSERVER1 -U sa -P abcd123'exec xp_cmdshell...
3 Oct 2013 by Homero Rivera
1. Suppose I have a table in MS SQL Server database that has an autonumber column (identity column). Let's call the table 'Sales' and identity column 'SaleID'.2. Then I have a StoredProcedure which inserts the total sale amount, triggering SaleID to generate (cause SaleID is identity) and...
4 Oct 2013 by PIEBALDconsult
No, it is not.SCOPE_IDENTITY[^](But I never use identity columns. They cause too much trouble.)
3 Oct 2013 by Ranesh M Raj
SELECT id FROM table ORDER BY id DESC LIMIT 1or SELECT LAST_INSERT_ID()
6 Apr 2014 by akhil.krish
this query give intime and outtime but i want total time and late time aslo....select distinct CE.USERID, CONVERT(Date,Localtimestamp) as LocalTime,(select min(TIMESTAMPS) from access_event_logs As MINCEwhere CAST(MINCE.TIMESTAMPS as DATE)=CAST(CE.TIMESTAMPS As DATE) AND...
16 Jun 2014 by Sampath Lokuge
The book is Reporting with Microsoft SQL Server 2012.
23 Jan 2016 by Fredrik Schultz
Introduction to Kaliko CMS - an open source content management system for ASP.NET MVC
13 Nov 2017 by Haroon Ashraf
This article helps beginners to generate over million records of random test data for a database object like books in SQL.
5 Jun 2013 by onemorecoke
I have a project where I get responses from emails that are sent out which may be 100 per second. Eventually I have to insert the information received into a table that will have many indexed columns for reporting purposes. My thought was to set up a primary table which is completely stripped...
5 Jun 2013 by onemorecoke
One solution I came up with was to fire this statement at an interval:Delete tblUnsubscribeLogQueueOUTPUT deleted.* INTO tblUnsubscribeLogI read by using the OUTPUT clause I could be assured that deadlocks would not occur because this was all one operation and I will only have one...
4 May 2020 by Member 11955245
Need some guidance here - Requirement- I have 1000 SQL servers and I have a scheduled task running on all of those which updates a table with just an integer, let's call it X (its a sum of some numbers). Now the ask is to create some sort of...
4 May 2020 by RickZeeland
Maybe you can use ApexSQL Propagate instead of writing a C# application: Multi-database SQL script execution | ApexSQL[^] Or take a look at this CodeProject article which uses SignalR: SQL Server Notifications on Record Change with SignalR and...
4 May 2020 by Dave Kreskowiak
Well, if you can't use 3rd party solutions, you're going to have to write a service that runs on all of the SQL Servers. This service would get the data it needs from the server it's running on and send it to a central SQL database. Your website,...
27 Aug 2015 by kirthiga S
Hi friendsIam having two datesExample : 2007-10-01 and 2012-08-24My requirement is I need number of months in each financial year between these two dates(ie)Financial Year Months2007-2008 62008-2009 122009-2010 122010-2011 122011-2012 ...
27 Aug 2015 by Maciej Los
DateDiff[^] is what you're looking for.To be able to calculate it for each year in date range, you have to use CTE[^]:DECLARE @startdate DATE = '2007-10-01'DECLARE @enddate DATE = '2012-08-24';WITH MIFY AS( --initial values SELECT @startdate AS StartDate,...
27 Aug 2015 by Herman<T>.Instance
Well.....Original found here[^]and with a bit playing:declare @dtFrom datedeclare @dtTo dateselect @dtFrom = '2007-10-01' ,@dtTo = '2012-08-24'select year(dt) [Year], count(*) as Monthsfrom (select top(datediff(MONTH, @dtFrom, @dtTo)) dateadd(MONTH, row_number()...