Click here to Skip to main content
15,888,218 members
Everything / Database Development / SQL Server

SQL Server

SQL-Server

Great Reads

by Wonde Tadesse
This tip/trick helps to set a default value for blob data type such as Image, VarBinary.
by Jovan Popovic(MSFT)
Mapping properties in EF model to database columns that contain JSON
by Steve Krile
Fully AJAX-enabled user control used to select names from a database in a drop-down format.
by Mubin M. Shaikh
Create time dimension with 24 hour plus values and time buckets in your data warehouse

Latest Articles

by GabrieleTronchin
A simple stored procedure to add at your database to keep it reactive
by GabrieleTronchin
Automatic creation of non clustered indexes using system SQL entities
by yuvalsol
POCO generating application for SQL Server
by scastelli
SQL resolves special character challenges, streamlining NULL parameter handling

All Articles

Sort by Title

SQL Server 

4 Sep 2013 by Karim2Ahmed
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string cs = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SATDB.mdf;Integrated Security=True;User Instance=True"; using (SqlConnection con = new...
4 Sep 2013 by Mike Meinz
Your error is in this statement:string sql = "GET_FILESTREAM_TRANSACTION_CONTEXT(), SELECT Trial_Addmission.PathName() from Sat";The Microsoft documentation for GET_FILESTREAM_TRANSACTION_CONTEXT[^] shows that it must be used in a Select statement.I've never seen anyone use...
18 Sep 2011 by ravibulls007
I want to deployment my c#.net project .i want set up that will be created after deployment will installmssql 2005,.net freamwork ,and the server name should be automatically willbe changed on my connection string in my project..So Please Help Me The Step To Do such type of...
18 Sep 2011 by OriginalGriff
You should not include SQL Server in your installation. There are a couple of reasons:0) You can only distribute SQL Server Express for copyright reasons - not SQL Server full version.1) They may already have SQL Server installed on the network. If so, then they will presumably want to use...
5 Jan 2011 by #realJSOP
You can also enclose your column name in brackets, like so: [Create Date]
25 Jul 2023 by Raf-Reyes
I'm new in VB.NET and I want to pass the value from vb.net to crystal report. I have a problem that the "Enter Parameter Value" keep asking a value even in my code there's already a value. When I remove this code I know "Enter Parameter Value"...
25 Jul 2023 by OriginalGriff
None of that code sets anything in report_Batch other than the two parameters. So at a guess, the command string (which we can't see) that the report is based on contains parameters you aren't setting. Use the debugger: find out exactly what...
25 Oct 2016 by sufyankadri
I want to create connection string and use it to all forms in my application but is showing error.Below is my code but its showing error "Object reference not set to an instance of an object"Please Help!!!!!!!What I have tried:mports System.Data.SqlClientImports...
25 Oct 2016 by Midi_Mick
You haven't instantiated connsql. See bolded code: connstr = "Provider=SQLOLEDB.1; Data Source=" & My.Settings.sqlservername & ";Initial Catalog=" & My.Settings.sqlDBname & ";Password=" & My.Settings.sqlPswd & ";User ID=" & My.Settings.sqlUserName connsql = New...
25 Oct 2016 by sufyankadri
connstr = "Data Source=" & My.Settings.sqlservername & ";Initial Catalog=" & My.Settings.sqlDBname & ";Password=" & My.Settings.sqlPswd & ";User ID=" & My.Settings.sqlUserNameconnsql = New SqlConnection(connstr)connsql.Open()
25 Feb 2013 by Muhamad Faizan Khan
in sql 2008 r2 sql configuration management-> sql server services here showing "remote procedure call fialed" please help what to dowhile sql instance name .\sqlexpress also not working not login please help
25 Feb 2013 by Prakash Thirumoorthy
hi,Have you enabled Allow Remote Connections in server properties?. If Not, refer the below link and check.http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx[^]regards,Prakash.T
5 Feb 2020 by maajanes
"String or binary data would be truncated. The statement has been terminated." Please explain about this exception.
7 Dec 2011 by uspatel
This exception occures when your datatype,size does not match with database field attributes.See Discussion
7 Dec 2011 by koolprasad2003
String or binary data would be truncated Error suggests your Datatype in Database is smaller than inserted value.1. Increase datatype length or decrease length of value before inseration.
3 Mar 2013 by marigold12
when user store data at that time size of data type is less as compared to required data type size then it gives such kind of error solution to increase your data type size...
10 Mar 2014 by SanSkun
Hi, Its the error because of data-type and what the size you are passing for inserting data to that field.Suppose i have declared a field named name varchar[20] and i am trying to inserting name of more than 20 characters then i will get an error like "String or binary data would be...
12 Sep 2011 by foxrox_1
Hello.I have a question about firing an event or call a method in a certain condition (eg if(datetime1 > datetime2) )Basically I need to send birthday emails to someone registered on my website at his/her birthday at Midnight.Then, each hour, I need to send a PM to me containing an...
12 Sep 2011 by Herman<T>.Instance
if (DateTime.Now > Midnight) counts for a complete day!Better create a service that runs on midnight once for the birthday emails and hourly for the PM
13 Sep 2011 by BobJanova
There's basically two options here.Best is if you either own the server or are permitted to run a service or cron job (sorry, scheduled process ;) ) on it. Set the service up to check once an hour for anyone whose birthday tripped in the last hour, and send you a PM (i.e. write to a database...
13 Sep 2011 by AditSheth
Create a job that will execute at MidNight. Step To Create JobNow in Job Find users which has birthday today and send email. To send email use Database Email Here you find step to send email
18 Aug 2011 by Karthik Harve
If I want to use something similar to %ROWTYPE type as in oracle with SQL SERVER 2008, what shall i do..? is there anything equivalent to %ROWTYPE in sql server 2008...??? Please help me out
18 Aug 2011 by Suresh Suthar
I think NO.Have you Googled this[^]?
18 Aug 2011 by NDebata
No direct equivalent is there in SQL server.But you could declare a variable of type table then you can use this table.
11 May 2012 by Jijutj
HelloI have an SQL query which is used to fetch the user details based on firstname. i.e, for e.g if 'a' is given, the users containing 'a' in their firstname should be listed.Im using the '%' operator in my Like Expression. When im fetching using any string such as 'a', 'ss','123' etc,the...
11 May 2012 by P.Salini
You are getting all records for % and _ because those are wildcard characters in Like operator.To know more go through thishttp://msdn.microsoft.com/en-us/library/ms179859.aspx[^]http://www.w3resource.com/sql/wildcards-like-operator/wildcards-like-operator.php[^]
11 May 2012 by Rockstar_
Hi friend,Keep % and _ in [] brackets defenitly it will come
11 May 2012 by Ranjith Reddy CSE
Dear Friend, Check this website, May be this will be ur Exact solution.http://www.w3schools.com/sql/sql_wildcards.asp[^]
11 May 2012 by VJ Reddy
The solution 1 and 2 are very good and clearly give the answer for including % or _ literal in the search expression. In case you want to enter the % _ in a normal way, for example from a TextBox from user input and then want to construct the filter expression, the following regular...
14 Oct 2013 by Rakshith Kumar
i can create a stored procedure and execute itIt will be likecreate procedure getallelementa(@startletter char(1))asselect * from where left(firstname,1)in(@startletter)Execution of this stored procedure will return you the details of all the customers whose name...
22 Feb 2017 by Man Down
When i executed my Query , i got a minus with month ! Can someone please point me in the right direction. Thanks.SELECT CAST(DATEDIFF(yy, WorkStartDate, GETDATE()) AS varchar(4)) +' year '+CAST(DATEDIFF(mm, DATEADD(yy, DATEDIFF(yy, WorkStartDate, GETDATE()), WorkStartDate), GETDATE()) AS...
22 Feb 2017 by Graeme_Grant
If the date on the left of the subtraction is less than the date on the right, then the result will be negative. Older dates are less in value to newer dates.
27 May 2013 by S.Dwaik
i have project used sql2005and when i need to join writeselect * from A ,Bwhere A.ID *= B.ID'( *= )' is no problem in sql2005but in sql2012 is not accept thatwhat i can Do to solve it problem???
27 May 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
This operator is discontinued after version 2005.You can still use it by setting the COMPATIBILITY_LEVEL to 80 in SQL Server 2008 R2.But you can't do it in 2012. There is no way to do this in 2012.Refer - Outer Join Operator (+) - Oracle to SQL Server Migration[^].SolutionInstead...
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...
4 Jun 2014 by jeevakumar.T
protected void Page_Load(object sender, EventArgs e) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { FormsAuthentication.RedirectToLoginPage(); } studtid = Request .QueryString...
3 Jan 2015 by Suvendu Shekhar Giri
Change this lineddlcoursename.Text = (cmd.Parameters["@COURSE_ID"].Value).ToString();withddlcoursename.SelectedValue= (cmd.Parameters["@COURSE_ID"].Value).ToString(); Also make sure that you have filled the dropdownlist before this line of code. This is the most possible cause of the...
23 Mar 2017 by Faizymca
I need some help with the following problem:I've been using a MS ReportViewer component in a website for a while now, but recently I've been getting the error shown below.The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both...
7 Oct 2013 by bluesathish
Go to Solution explorer and remove all 'Microsoft.ReportViewer.WebForms references. Then Add the references from your latest directory (VS2008). Go to Build menu and Click clean solution and Click Rebuild solution.Regards,BlueSathish
7 Nov 2015 by Venkat Chaitanya Kanumukula
check this link on the resolution to bind old and new Dll's in the config.http://stackoverflow.com/questions/9429277/problems-with-reportviewer-assemblies-in-vs2010example below ...
23 Mar 2017 by Member 13080469
on web.config review assembly info. appear two times "Microsoft.ReportViewer.WebForms" one with 12.0.0.0 and other with 11.0.0.0. just get one of this.
1 Jun 2012 by samu4u
Unless you have an explicit ORDER BY clause, there is NO implicit ordering (there is no "original order from DB") in a SQL Server environment. mean to say, in a small database of say, 1 Lak of records, it does not preserve insertion order (even though there are no concurrent inserts). Even...
1 Jun 2012 by Maciej Los
Order by may not change order in a database. Yes, it's used only for listing the data.More at: ORDER BY[^]
1 Jun 2012 by Clifford Nelson
This is what I found out:SELECT is a set-oriented operation and, as sets are unordered, no specific order in the resultset is guaranteed, unless you explicitly use ORDER BY.
4 Aug 2013 by Mehdi Gholam
You can only delete data with delete and truncate, to delete a database you have to use drop database, see: http://technet.microsoft.com/en-us/library/ms178613.aspx[^]
4 Aug 2013 by OriginalGriff
You can: http://www.w3schools.com/sql/sql_drop.asp[^]
4 Aug 2013 by Status BreakPoint
The delete and truncate effect on table data. Not database. If you want to delete database, you can use drop statement. http://msdn.microsoft.com/en-us/library/ms178613.aspx[^]
4 Aug 2013 by Adarsh chauhan
You are right that truncate is a DDL command.TRUNCATE command works on table data not on table structure,It is used to delete all the rows from the table and free the space containing the table. TRUNCATE command is used when you have to use that table again as if a table is dropped, all...
25 Oct 2012 by Aadhar Joshi
Currently i'm using "Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) Jun 17 2011 00:54:03 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) " version for sql server.I have added danish language registry to...
26 Oct 2012 by Sergey Alexandrovich Kryukov
Please see my comment to the question. As I say, your problem is not described, but you need to use Unicode, and Unicode SQL data types such as NCHAR, NVARCHAR2, NCLOB. Please...
30 Oct 2013 by ssss0001
Question:-(Identity Column value suddenly jump to 1000 in ms sql server). i m using Sql Server 2008 R2 column is identity column(1,1) and primarybut this problem create online server(Example:- 1,2,3,4.......767,1767,1768...)please help Solve this Problem guys.........
30 Oct 2013 by Mehdi Gholam
The Identity function will increment every time anything is inserted even if you rollback within a transaction or delete the tailing rows (if you delete the last row with id of 1000 then insert a row you will get the id of 1001).
15 Sep 2010 by Sandeep Mewara
It might be surface area configuration error or sql service configuration issue. Have a look at this thread for potential reasons and resolutions: Resolving A network-related or instance-specific error occurred while establishing a connection to SQL Server[^]If needed, See steps for setting...
14 Sep 2010 by Hossam443
i want to make a test connection module for my application which test if the server is found on a particular IP with user name and passwordsome of our servers don't have password so it is just a user name when i call the method to check the database connection this exception is...
7 Mar 2012 by punkrazz
SqlException was unhandled by user code.a network related or instance-specific error occurred while establishing a connection to server. The server was not found or was accessible. Verify that the instance name is correct and that SQL server is configured to allow remote...
7 Mar 2012 by Herman<T>.Instance
In Sql Server Configuration Manager set Network Configuration->TCP/IP to Enabled
7 Mar 2012 by thatraja
Troubleshoot SQL connectivity issues[^]
12 Mar 2012 by Dean Oliver
Your server could be down. or the connection string may be incorrect. There are many scenarios though.
12 Oct 2010 by Dave Hausler
Useful trick for handling numbers with variable length implied decimal points
6 Dec 2009 by nav234
Hi,I need to select random checkboxes in a Tree view,which areretrived from Database (SQL Server).My project is windows based and using WPf. Im using VB.net and sql server database.Can anyone help on this issue ???Thanks in advanceRegardsnaveen...:~
22 Feb 2010 by Rahul P Nath
Hi,For this you can either use a property in your entity,say IsSelected,and bind the checkbox's(in the datatemplate of the treeviewitem) IsChecked property to it.Or get the datatemplate from the treeview item,which can be obtained using the ItemsContainerGenerator and set the IsChecked...
19 Jun 2013 by VIP Venkatesan
Hi friends,In my project i'm using excel data import concept.in that i've import one excel named "Sheet1"..if i imported the same excel again it should not be imported. andit should alert like "The Excel File Already Imported".Is this possible??Regards,Venki
19 Jun 2013 by Mukesh Ghosh
Hi,Yes possible, in case you need to keep imported excel file along with sheet name in Database or any text file so every export you need compare with previous one.
19 Jun 2013 by DaveAuld
Read the import file, generate a hash of the file (SHA-256 etc.) store it.If the next file has the same hash, then chances are you have already imported the file already.As you have not really given much else to go on, this is the best option I can think of at the moment.
26 Jun 2013 by VIP Venkatesan
Hi Friends, Can anyone solve this query and help me??create proc Sp_DespatchMachine@docno intasselect distinct m.mcidno,m.mcrefno,t.buyercomp,t.buyerfactfrom Tbl_Machine m join Tbl_Asset t on m.mcidno = (select t.machineid from Tbl_Asset t where t.deliveryno=@docno) WHERE...
26 Jun 2013 by Pallavi Waikar
Try this querycreate proc Sp_DespatchMachine@docno intasselect distinct m.mcidno,m.mcrefno,t.buyercomp,t.buyerfactfrom Tbl_Machine m join Tbl_Asset ton m.mcidno = (select top 1 t.machineid from Tbl_Asset t where t.deliveryno=@docno)WHERE t.deliveryno= @docno
26 Jun 2013 by Simon_Whale
I would change your query to this CREATE PROC DespatchMachine @docno INT AS SELECT DISTINCT m.mcidno,m.mcrefno,t.buyercomp,t.buyerfact FROM Tbl_Machine m INNER JOIN Tbl_Asset t ON m.mcidno = t.machineid WHERE t.deliveryno= @docnop.s. Inner Join will only return the...
25 Jun 2013 by VIP Venkatesan
Hi friends,i've 60 columns in my tablei need to select all values except one value.select * from mytable will select all 60 columns.But i need 59 columns only. for example i want to neglect the 60th column value.so i need to write a query likeselect...
21 Jun 2013 by salah9
you need to provide ID or some condition to remove the 60th tableselect * from mytable where mytable.ID=60hope this helps you..
21 Jun 2013 by Mike Meinz
You need to write query like select column1,column2....column59 from mytable.It is a best practice to always name the columns in a query. This helps when new columns are added or old columns are deleted. With SELECT *, a new column recently added to the table would be retrieved and the...
22 Jun 2013 by RedDk
Here you go. This is the sample data from "vvexample(td).txt" (Copy and paste it)1 1 0 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 0 1 0 1 1 1 0 0 0 1 0 0 1 1 0 1 02 1 0 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 0 0 1 0 0 1 0 1 1 0 1 0 1 1 03 1 0 1 1 1 1 0 1 1 1 0 0 0 0...
24 Jun 2013 by Adarsh chauhan
Hi,better you select columns in the traditional way like select col1,col2,.... from table(as it will be faster then the SP below)oryou can try following sp,Create PROCEDURE [dbo].[TEST] @Schema varchar(10), @Table varchar(20), @ColumnExclude Varchar(20),...
25 Jun 2013 by gvprabu
Hi...Check the below sample Query.-- Table CreationCREATE TABLE Test(Col1 INT,Col2 INT,Col3 INT,Col4 INT,Col5 INT)-- Local variable DeclarationDECLARE @TableName VARCHAR(100), @SqlQuery NVARCHAR(1000), @ExcludeColPos INT-- Assign default valuesSELECT...
19 Jun 2013 by VIP Venkatesan
Hi Friends,Please solve this Query create proc Sp_test1 @date1 nvarchar(50), @date2 nvarchar(50)as select distinct m.mcidno, CONVERT(VARCHAR(10),h.hdate,103)as hdate from Tbl_Machine m inner join Tbl_History h on m.mcidno=h.mcidno where h.hdate between @date1 and...
19 Jun 2013 by kapil.sharmaA3
Hi Dear Please change your 103 conversion Code to 120 , and increase varchar(10) to 20as like this example :select CONVERT(VARCHAR(19),GETDATE(),120)
19 Jun 2013 by Stephen Hewison
Are you sure the culture details are correct within SQL?If the date format for the culture is wrong then it could be trying to find the 20th month of the year.Try writing your params like this '20 Jun 2013' and see if you still get the problem.
19 Jun 2013 by Mukesh Ghosh
Use This convert(datetime, @date1, 103) if you are using SQL SERVERLike in you case something likereate proc Sp_test1 @date1 nvarchar(50), @date2 nvarchar(50)as select distinct m.mcidno,convert(datetime,h.hdate, 103) as hdate from Tbl_Machine m inner join Tbl_History h on...
19 Jun 2013 by Aarti Meswania
change in spAlter proc Sp_test1@date1 datetime,@date2 datetimeasselect distinct m.mcidno, CONVERT(VARCHAR(10),h.hdate,103)as hdatefrom Tbl_Machine m inner join Tbl_History hon m.mcidno=h.mcidnowhere h.hdate between @date1 and @date2Executionexec Sp_test1 '2013/05/06',...
15 Jun 2013 by VIP Venkatesan
Hi friends, i've developed my project using visual studio 2010. i'm using crystal report CRforVS_13_0_1 in my projet.my project is working fine in my system. after publishing it i want to host it in my server system.My Server doesn't have visual studio 2010 and crystal...
16 Jun 2013 by manojbabupr
Try adding the Dll of crystal report which ur using
5 Jun 2013 by VIP Venkatesan
Select Name from Table1 Result: Name AAAA BBBB Select Name from Table2 Result: Name CCCC DDDD i need a result like Name AAAA BBBB CCCC DDDDWhat is the query for this?
5 Jun 2013 by Maciej Los
SELECT [Name]FROM Table1UNION ALLSELECT [Name]FROM Table2Morea bout: UNION (T-SQL)[^]
5 Jun 2013 by nandakishoreroyal
SELECT *FROM Table1UNION ALLSELECT *FROM Table2
7 Feb 2011 by vijay.darji2
I was live my website about a few day ago. It was developed in ASP.Net, C#, and Ms access 2003, SQL server 2005 is used as a database. HTML page is display well, but when we open .aspx page it will not display and giving error. Please somebody help me to sort out this problem
7 Feb 2011 by Parwej Ahamad
Check with your provider, is he providing .Net framework support?
7 Feb 2011 by velmahesh
Check the Code based on Error Message..
24 Mar 2011 by beginner1984
I have to create an SSIS package to automate the migration of data from a .csv file format to the SQL Server. But my .csv file contains a lot of information ( initial status information about wireless sensors ) before the data in the tables that I actually need to work with. Since the entire...
25 Mar 2011 by Corporal Agarn
Set up a stored procedure that takes in all data then only saves to the final table the records you want.A better way would be to use a .NET interface to automate the trim.
25 Mar 2011 by Wendelius
Hi,You could use OPENROWSET[^] in the SSIS package to read the data from the file. If the amount of non-interesting rows is known you can define how many rows are skipped in the beginning. The same can be done using bcp[^] if that's more suitable.
18 Jun 2012 by Nikil0012
HelloI have created code for creating a .csv file in sql server stored procedure.Now the file is written in my d drive.Now the file is coming correctly till 10 may 2012 and after that the .csv is not coming in my d drive.can some one suggest me the reason and solution for this.
14 Jul 2012 by jschell
Possible reasons.- The stored proc did not return any data and because there is no data the file was not written.- The file was written but somehow it got deleted.- There was an error when the write was attempted by the proc but the proc was not written to account for that possibility so...
20 Dec 2013 by kingsa
Hi, I have created wpf application and i have added new .mdf file, but the file storing data permanently like as normal database,it stores temporarly,when application closes it loses all data , i want to install into client application what are precautions i need to take to ssave data...
15 Jun 2012 by Rick Bassham
How to use the SqlChangeMonitor with the new MemoryCache class in .NET 4.0.
13 Jun 2011 by gopal duggirala
hello there,how do i access an SQL database server using .NET for establishing connection and accessing stored data?thank you
13 Jun 2011 by Richard MacCutchan
Take a look at some of these links[^] for more information.
13 Jun 2011 by RaviRanjanKr
For Establishing Connection Take a look http://www.connectionstrings.com/[^] and for Overall Query you should Learn ADO.NET so Start from Here-MSDN Library[^]Start Learning and after that if you have any specific question then feel free to revert back here.