Click here to Skip to main content
15,886,919 members
Everything / Database Development / SQL Server / SQL Server 2005

SQL Server 2005

SQL-Server-2005

Great Reads

by Wonde Tadesse
This tip/trick helps to set a default value for blob data type such as Image, VarBinary.
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
by Max Paulousky
This article presents the techniques and caveats of building Silverlight applications that can be notified about database state changes via polling duplex. WSHttp binding and CLR triggers are used to implement the solution as well.

Latest Articles

by Narapareddy Shyamprasad
SQL Dynamic Pivots
by Luca Astolfi
User defined procedure for make an HTML table from T-SQL Select statment
by JasonShort
Wouldn’t it be handy if you could use regular expressions (RegEx) in your SQL code?  You could do some really advanced queries through the ability to specify regular expressions rather than just the simple like % matching you normally use. SQL CLR can do that!
by Ebenezar John Paul
An Ideal Code Review Checklist that applies for most programming languages

All Articles

Sort by Updated

SQL Server 2005 

N 19 Apr 2024 by Member 16247227
dateadd(day,1,eomonth(dateadd(month,-1,convert(date,getdate()))))
5 Feb 2024 by Innocent Obie
Hi, Try this First, enable ad-hoc queries like so: sp_configure 'show advanced options', 1; RECONFIGURE; GO sp_configure 'Ad Hoc Distributed Queries', 1; RECONFIGURE; GO Then run the below query: SELECT a.* FROM...
27 Oct 2023 by Ubaid ur Rahman IT
I have created a web application using ASP.NET C#, SQLServer 2005. In this, the first page is login page... if user has the username and password, he can login. I have many Inner pages. User can open the application, copy and paste the Inner...
30 May 2023 by Juan Davel
Hey Peeps,I have a small (possibly stupid) error happening in my code. Not sure why it is happening but I do hope someone on here can shed some light on this.First things first, I have a dataset that requests a single value from the database:SELECT [menu$IsActive] FROM [Menu$Main]...
2 Apr 2023 by Dnyanesh Wahiley
Hi Everybuddy i m working on Game Application...! and there i need a convert stored procedure in c# code..! i tried to make it but could not achived...! plz help me my code is Followed.....!NOTE:- i dont want to call this procedure in My Application..! just convert this procedure into...
19 Sep 2022 by BindassFrind
I want to get only Time from DateTime column using SQL query using SQL Server 2005 and 2008 Default output:AttDate==2011-02-09 13:09:002011-02-09 14:10:00I'd like this output:AttDate Time==2011-02-09 13:09:00 13:092011-02-09 14:10:00 14:10
31 May 2022 by Varun Sareen
Dear Friends,I am facing a problem related to SQL query. I need to update a table column values (data type 'int') in increment/decrement on single update query. Like..there are values in column1 as:-Column11234...The result should...
31 May 2022 by waqi23
update mytable set IDSEQN_NUMB = rownum where IDSEQN_NUMB is null
1 Mar 2022 by skcwebworld
drop table if exists citydistance create table citydistance ( city1 varchar(100), city2 varchar(100), distanace int ) insert into citydistance values ('Delhi','Mumbai',5000) insert into citydistance values ('Mumbai','Delhi',5000) insert...
1 Mar 2022 by Jörgen Andersson
You need to update the table twice. First sort the table on City1 and City2 so ('Mumbai','Delhi',5000) becomes ('Delhi','Mumbai',5000). Something similar to: UPDATE citydistance SET City1 = City2 ,City2 = City1 WHERE City1 > City2 Then remove...
28 Feb 2022 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
2 Feb 2022 by fwr
I want to write a store procedure to insert data into table and also to check whether same username is already exist?If yes,then exception throw as useralrady exist.I have written the Store procedure as:ALTER PROCEDURE [dbo].[Useradd]@username varchar(20),@pword...
2 Feb 2022 by Member 15522211
ALTER proc [dbo].[MyImp] @username varchar(20), @pword nvarchar(20), @empname varchar(20), @email nvarchar(50), @designation varchar(20), @isActive int AS BEGIN declare @result int If exists(select * from Users where...
16 Jan 2022 by MichealRay
Hi friends,I have a database where numbers are displayed in English Format, does anyone know how to display them in Arabic letters Using SELECT Query? like collate ARABIC_CI_AIIs it possible? Thanks
14 Oct 2021 by avishekrc
Hi,The requirement is follows:I have a table called tblactivity,where I have a column as checkedin_flag.This checkedin_flag column can contain values [0,1,2,4,6].Now the corresponding text values are as follows:0->Incomplete1->Complete2->Posted4->Posted6->CancelledNow I need...
14 Sep 2021 by Viswanthan.M.
Hi, Kindly send me the query to change the first letter to upper case in sql server 2005.Thanks,Viswanathan.m
14 Sep 2021 by sayf riseup
UPDATE table_name SET column_Name= UPPER(substring(column_Name,1,1))+lower(substring(column_name,2,20)))
5 Sep 2021 by Pranav Kalyani
CREATE TABLE #emp( Dept varchar(100), Emp varchar(100), Sal numeric(18,2))INSERT INTO #Emp values('Comp','A',6000)INSERT INTO #Emp values('Comp','B',7000)INSERT INTO #Emp values('Comp','C',10000)INSERT INTO #Emp values('Comp','D',9000)INSERT INTO #Emp...
5 Sep 2021 by Member 15041281
select * from(select row_number() over(partition by dep order by salary desc)rownum,* from emp)dep_db where dep_db.rownum
26 Jul 2021 by vivektp
My SQL query is returning a value like 'a,b,c'.I want to replace last comma with 'and', finally it should looks like 'a,b and c' . Please help.
26 Jul 2021 by Er Sagar Mahajan Pune
--Here is a simple solution, might be it will help you. DECLARE @str VARCHAR(100)='a,b,c' -- pass any comma separated string here SELECT REVERSE(STUFF(REVERSE(@str),CHARINDEX(',',REVERSE(@str)),1,' dna ')) --Output a,b and c
7 Jun 2021 by Boipelo
I am not sure where to post this question, I also hope I worded it correctly.I need help with sql, story below:I have an table with starts and end date, including time(Like timetable). It’s working fine. I have issues conflicts.Let’s say I have sql table with the below informa ...
7 Jun 2021 by aesalan
You can check if two dates lies between two dates by following query SELECT * FROM [vacation] where ((DATEDIFF(d,'2021-06-30',startdate) = 0) or (DATEDIFF(d,'2021-06-30',startdate)
6 May 2021 by satpal 2
How to Count blanks in any particular column of table in sql server 2005?
6 May 2021 by Member 15187090
SELECT COUNT(column_to_count) AS count FROM table
5 May 2021 by syedkhaleel
i have uploaded the site to some hosting server.im using session to track user who is logged in..im using state server mode to store user session inforamation in out process...but while running website im getting the following error.how to start the state server my control...
5 May 2021 by Saleeb Girges
Go to Services >> ASP.NET State Service >> start
28 Feb 2021 by priya naidu1
Hello,Can anyone help me for how can i convert numbers into words in two ways:Ex.1: 124 i want to write like this (One Hundreed Twenty Four)Ex.2: 124 i want to write like this (One Two Four)Regards,Priya
25 Sep 2020 by Gopal Rakhal
Hi every one i have search a lot for this error "SELECT permission denied on object 'tablename', database 'db1', schema 'dbo"but m not getting exact answer, m not able to understand the where the problem lies exactly, why its shows this error and what is solution for that...Plz help/reply...
25 Sep 2020 by Member 14948524
Just go to the properties of ur deàired table And go to the permission and select the use as public. And the check the queris required Below. Done enjoy......✌️✌️
9 Aug 2020 by ks ravi
hi all,i've a Image column and wanted to check whether it is empty in StoredProc.And i also tried like this,if(@Imag=Null),but showing error likeThe text, ntext, and image data types cannot be compared or sorted.please reply with an example
24 Jul 2020 by Member 7909353
I want to get string value(designation) from Login table throught stored procedureCREATE PROCEDURE logincheck(@intoption int=0,@emp_name varchar(20)='',@uid varchar(20)='',@p varchar(20)='',@add varchar(20)='',@desig varchar(20)='',@np varchar(20)='')asbegindeclare...
24 Jul 2020 by Member 11882966
firstly you return string value in store procedure its wrong. it is always return int value if you want return string value using select statement. for Ex select @designation As Designation
16 Jul 2020 by SravanM
Using SET how can i store multiple Values? When I'm trying to assign multiple values (which are extracted from a database)like this DECLARE @Level4 varchar(255) SET @Level4 = '[A,B]' i'm not getting a proper result. Can any one let me...
16 Jul 2020 by Maciej Los
If i understand you well... You can declare variable type of table: DECLARE @tmp TABLE(Column1 As VARCHAR(255)) Then: INSERT INTO @tmp (Column1) SELECT OtherColumn FROM YourTable WHERE YetAnotherColumn = 'SomeValue' To get values from table...
8 Jul 2020 by ritesh88sharma
Hi,I want to make a photo gallery. But I have a problem to show the image in the list view. and images are stored in the database(SQL Server 2005).I want to show image in a table format and if I click on any image, this will open into a new window with a big size. I am using a listView But...
18 Jun 2020 by Chris Rokusek
SQL server can read the file directly from the filesystem if the SP runs under someone with the bulkadmin server privilege. This bulk command worked for us: update someTable set FileData = (select * from openrowset(bulk ''' + @filepath + ''',...
18 Jun 2020 by Vvr15
Hi,Could you please suggest me the best way to save the huge files in the database using c# without putting the load on memory. At present i m reading the file into BinaryReader and reading it into chunks and sending it to the database. I which takes lots of memory space while execution....
29 May 2020 by vahid_erad
hi freindsi have a table with 250 record , i want select 100th to 200th rows , please guide me.
11 May 2020 by Ealps_grp
Can any body help me out how i can update data from one server database table to another server database table using sql server 2008 and through sql queries?
23 Apr 2020 by S.Prasath
Hi All, I am developing an asp.net c# web-application to sign documents on the server side. I am using a USB dongle to sign the documents. When i developed on the development box, I can able to sign the document. But when the same code is hosted on IIS , I cannot able to sign the...
21 Apr 2020 by Chiranthaka Sampath
I type the following statement in SQL server 2008 to drop a foreign key.ALTER TABLE BOOK DROP FOREIGN KEY (FK_AUTHOR_NUMBER)But after executing the command I got the following error.Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword...
21 Apr 2020 by Member 11326001
var result = _context.ctx.GetAll(); _context.Entry(result).Collection(o => o.NavProp).Query().Where(p=> p.NavProp.Id == someId).tolist();
21 Apr 2020 by tux@ddictor
hello everyone.am trying to include navigation properties that meet a specific condition but the include method doesn't support that.so how can i solve this?the code i wish it to work is this:ctx.GetAll().include(o=>o.NavProp.Where(p=>p.Id==someId);using Projection return...
13 Mar 2020 by Rashmikants Monpara
hihow to validate two date like first date is less then second datethanks
28 Feb 2020 by Member 14758249
Consider two tables A , B . The table A has the following fields like ID , Product_Key, table B has Product_Key. Table A Table B ID Product_Key Product_Key 1 05 05 2 06 ...
28 Feb 2020 by Ganesh_mca
Hi,i have two tables one for lets take A table it has one column called 'id' and it has row values like 1,2,3,4,5. and B table has column 'id' and it has row values like 3,4,and i want to display the output like only 1,2,5. Table A Table B id ...
5 Feb 2020 by maajanes
"String or binary data would be truncated. The statement has been terminated." Please explain about this exception.
30 Jan 2020 by Mansoor Anwar
Very Simple Solution C# Text query = "insert into Customer (CustomerCode,LdegerCode,CustomerPicture) values ('0001','9999',NULL)" Sql query Text insert into Customer (CustomerCode,LdegerCode,CustomerPicture) values ('0001','9999',NULL)
30 Jan 2020 by Flower@12
I want to pass Null value or empty bytes for image field in sql What I have tried: My Code is below If Not pic Is Nothing Then imageConverter = New ImageConverter() imageByte = DirectCast(imageConverter.ConvertTo(pic, GetType(Byte())), Byte()) ...
28 Jan 2020 by WinnieMeeKun
using (SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\meekun.poon\\My Documents\\Visual Studio 2008\\Projects\\TrackLocation\\TrackLocation\\barcodePrinter.mdf;Integrated Security=True;User Instance=True")) { ...
17 Jan 2020 by Member 13091969
METHOD 1 - WHILE LOOP AND REPLACE By Using WHILE Loop, we can check the occurrences of double spaces, as Loop Condition. Till the occurrence (Loop) fails, we need to alter every Double Spaces as Single Space. DECLARE @TestString VARCHAR(200); SET @TestString=' Ex ample St ring ...
17 Jan 2020 by chetan virkar
HEllo Everyone,I am Using Sql Server 2005i want remove double space or enter from the column of table for that i am using following codeFor that I am using RemoveSpaces Functionthe function Contain following codeCREATE FUNCTION RemoveSpaces (@InputString VARCHAR(1024)) ...
8 Jan 2020 by Member 14711143
could you please give me the vb code as well
8 Jan 2020 by Namit KB
I want to Expand\Collapse gridview inside another gridview on click of a button. Any help is appreciate. Thanks in Advance..........
5 Dec 2019 by vinay.sarmalkar
Dear All,I got bold on the above question in an interview recently. This question i faced many times but yet i have no solution for the question. So please consider the following example and provide me a proper answer of the question this will be a great help.Example:table name -...
1 Dec 2019 by Member 7909353
I want to fetch column value from table in javascript.
26 Nov 2019 by josh-jw
i want to exclude saturday and sunday while calculating date.for example if my date period is 5, and calculating from today , i need the result day as 12/26/2012.
26 Nov 2019 by Sohail Arshed
This is an old post but it might help someone. This query returns the exact days, months and hours between two dates excluded All Sunday(s) and Monday(s): ``` declare @d1 datetime, @d2 datetime select @d1 = '11/25/2019 12:00:00', @d2 = '12/02/2019 12:00:00' SELECT (DATEDIFF(MINUTE, @d1, @d2)...
12 Oct 2019 by om3n
I want to enter data NULL (rather than numeric numbers, etc.) to the field of type integer. I use the following code:Dim Col2 As Nullable(Of Integer) = NothingOpenDatabase()Command.Connection = ConCommand.CommandType = CommandType.TextCommand.CommandText = "INSERT INTO...
11 Oct 2019 by dhage.prashant01
Hello Friends,I'm trying executing dynamic query using EXEC SP_EXECUTEbut it gives error saying:Procedure expects parameter '@handle' of type 'int'.Here is my procedureALTER proc [dbo].[sp_StudioReleaseChallan_sel] ( @Criteria nvarchar(4000)='', @startRowIndex int=0, ...
4 Sep 2019 by ErBhati
Hi Experts I am New to WPF. I have a form that contains a Datagrid with autogenratecolumns false.I have 6 columns .I want insert data into sql table through these columns. I have button "Add More" by this i want to add a new row in datagrid .I want to insert all data of DataGrid By...
24 Aug 2019 by Rasadul Alam Rashed
I am using SQL server 2008.In Stored Procedure (SP) I have string type variables. Now I want to store some string type value in this variable. But if the string size is less than 4000 then it works nicely. But when the size is over 4000 then it does not work. DECLARE @SQLString...
24 Aug 2019 by Member 14566715
You Could Try Declare @SQL as nvarchar(Max) ,@SQL2 as nvarchar(Max) -- Just Sample -- each variable max 4000 character, so be wise in splitting your syntaxs Set @SQL = 'Select * ' Set @SQL2 = 'From table A' EXEC (@SQL+@SQL2) Note if your dynamic string lenght more than > 8000 character...
28 Jun 2019 by sathish chandran
Hai Friends,Im doing my final year project. I'm using asp.net as front end and sql server as backend. I implemented qrcode generator using MessagingToolkit.dll file to generate qrcode for a particular number. In my project i have to take a printout that qrcode image and i have to scan it...
30 May 2019 by Sachin gulati
hi, i have just installed sql server 2005 in my windows 7.with instance name sachin and with mixed authentication. but now i am not able to connect to the sever.this error window shows whenever i try to connect."Cannot connect to sachin.Additional information: A network-related...
28 Mar 2019 by murkalkiran
Dear friends I have data base having data for 12 months now i want to pick the data only for one month say i want report of june 2013 what is the query for that user will select month and year
25 Mar 2019 by Member 14196068
Select * from student where month (12_march_2010)=@month
5 Feb 2019 by abhinavvijay
While attaching the mdf & ldf file in sql it is showing errorUnable to open the physical file "D:\Database1.mdf". Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error: 5120)
5 Feb 2019 by Member 14118695
I was struggling with same issue for few days. Solution :- Give FULL Control to the SQL Service account on the folder where .mdf , .ndf and log files staying. Note:- If SQL Service account can not be added to network path folder in that case give Full Control to Everyone on the folder where...
22 Jan 2019 by Member 14126984
your code is correct just reurn the @result value and pass it to your method in C# for ex. int id=insertdetails(); where insertdetails is the method in 3 tier architecture here you can write if condition if id is 1 "Details already existed' else"Details inserted" ALTER PROCEDURE...
2 Nov 2018 by kunalkumarsingh
Hi every one,please see following queris and give me a solution."update emp_table set salary=500000"(Here i failed to give condition ,obviously all record will be updated)Here i want to do undo any how becouse in this table there is more than Ten thousand records and for different...
24 Oct 2018 by prabaran
Sir, I have created one website and host in server, the website is work very well, I Create tables in MS SQL SERVER 2000. In tables all rows and columns data are affected by virus. so how can i remove the virus from table OR how to avoid virus affected in table. Please help me to remove the...
23 Oct 2018 by #realJSOP
This isn't a practical approach because there's a possibility that every record will have a different combination of null column values. When you do a query, *ALL* rows will have the same columns (that you specify in the SELECT statement).
23 Oct 2018 by pkarthionline
Hi, sql server select query: ================= I have memberTable have 150 columns, in this 150 columns 70 columns mandatory columns remaining columns based on condition display columns,null value columns should not display. example: I have 50 records in my memberTable. first 70 columns...
20 Sep 2018 by OriginalGriff
Try: objCmd.Parameters.AddWithValue("@EmpPhoto", SqlDbType.Image).Value = DBNull.Value Interesting. That doesn't work...Nor does this: try { using (SqlConnection con = new SqlConnection(strConnect)) { ...
20 Sep 2018 by Flower@12
I want to get two Output values at the same time from the sql stored procedure .I am using visual studio 2005 and sql server 2005.In my stored proceudre there was no problem it returns Two Values. @EmpSid @RevisionNo 79 2 What I have tried: My code is here MySID =...
20 Sep 2018 by Richard Deeming
Select ... from tblEmployeeMaster where SID = @EmpSid UPDATE tblEmployeeMaster ... WHERE SID = @SID SET @EmpSid = @SID That first WHERE clause should be using @SID, not @EmpSid: SELECT @RevisionNo = RevisionNo + 1 FROM tblEmployeeMaster WHERE SID = @SID
19 Sep 2018 by ZurdoDev
As mentioned in the comments, @RevisionNo is null. The error has nothing to do with multiple output parameters. The error should be pretty clear. You are trying to put null into a column that does not accept null.
17 Sep 2018 by Flower@12
I Stored Image in sql table using sql server 2005.Now I need to check Whether the image already exists or not. My Code is Below What I have tried: CREATE PROCEDURE sptblEmployeeProofDetail ( @SID numeric(18),@EmpSid numeric(18),@ProofTypeSID numeric(18),@ProofNo nvarchar(50), @ProofPath...
17 Sep 2018 by Maciej Los
Well, the only way to compare images on SQL server side is to CONVERT[^] them into VARBINARY data type: ... WHERE CONVERT(VARBINARY(MAX), ProofImage) = CONVERT(VARBINARY(MAX), @ProofImage) Note: i'm not sure that CONVERT fuction is available on MS SQL Server 2005, because of MSDN...
17 Sep 2018 by OriginalGriff
In addition to the change to VARBINARY suggested by 0x01AA, I'd suggest that you don't use it in the WHERE clause, although it will work. Instead, add an extra column to you table containing a Hash value (MD5 or a basic SHA will do for this, there is no need to be secure) and compare the hash...
9 Sep 2018 by Member 13978324
--I tried in Ms-sql DECLARE @MONTH INT,@YEAR INT SET @MONTH=1 SET @YEAR=2018 DECLARE @DATA TABLE ( ID INT IDENTITY(1,1), DATE DATE, WEEKNAME NVARCHAR(10) ) ;WITH CTE AS ( SELECT 1 V UNION ALL SELECT V+1 FROM CTE WHERE V+1
9 Sep 2018 by Jαved
Hello friends, i have developed one application on "Employee Attendance" for which i want to calculate sundays in a particular month ex.november. how do do it. no matter whether it's in .net or in SQL. i just want to calculate sundays.and i want it to automatically insert...
30 Aug 2018 by Richard Deeming
To install SQL 2005 on Windows 7, you'll need at least SP3. Is it possible to install Microsoft SQL Server 2005 on Windows 7? - Super User[^]
30 Aug 2018 by Flower@12
I need to install sql server 2005 in windows 7 32 bit os but it shows warning message like "Operating System Compatiability Issue" What can i do???? The error Message is Shown in Below SQL Server Edition Operating System Compatibility (Warning) Messages SQL Server Edition Operating System...
16 Aug 2018 by Narapareddy Shyamprasad
24 Jul 2018 by Member 13924556
I solved this by referring properties of login user under the security, logins. then go to User Mapping and select the database then check db_datareader and db_dataweriter options.
19 Jul 2018 by Member 13919202
Another way I think is simple, is by appending the items to a single string using some symbol between the items(- or _ or &, etc) and store it in the database. While reading it, you can parse it to an ArrayList with a single line of code. I use this because sometimes, I don't know how many items...
19 Jul 2018 by beginner in C#.net
I have an ArrayList: ArrayList arrayc = new ArrayList(); arrayc.Insert(0,"asd"); arrayc.Insert(1,"wet"); arrayc.Insert(2,"wertWER");I want to store it in a database. How can I achieve this?
18 Jul 2018 by RDBurmon
IS there is other tool which will format sql query / procedure.like all the keyword in capital letter, stuctur if block/ nested if block, loop. etc....I know the toad software i am asking other than that.It may be outside sql server 2005 or internal in sql server like integrated third...
24 May 2018 by Member 13843821
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Try cmbserver.Items.Add(My.Computer.Name.ToString & "\SQLExpress") cmbserver.Items.Add("Localhost\SQLExpress") Catch ex As Exception ...
24 May 2018 by Vipin Sharma
i am creating a application in vb2010 and use sql-server2005 as backend.i want to install it other's computer . for this connection string is a problam becouse i have to change it i allready create the setup bt it wont work .my connection string is : Public sqlc As New...
2 Apr 2018 by 3796068
Hi all,How to store data in two different tables when we click the button.Using Stored procedure how to do it.Suppose I have a 2 tables named as customer and product.In customer table I have 4 fields custid,custname,custaddress,prodidIn Product table I have 3 fields...
1 Apr 2018 by Wendelius
What I would suggest is that instead of storing different months as columns you'd store them as rows in a new table. Each row would have a date column defining the month and another column defining the actual value plus a reference to the parent table. Consider following table example ...
1 Apr 2018 by Member 12245539
I have two tables first one Fee_Payable_to_Students and another one Fee_Assign_Waiver_to_Students it contains value as Fee_Payable_to_Students f_co |S_Adm_No | apr | may | june | jul | aug | sep | oct | nov | dec | jan | feb | mar 1 |s_1 | 5 | 5 | 5 | 5 | 5 | 5 | 5...
1 Apr 2018 by Member 13757419
A many-to-many relationship must be broken down into multiple one-to-many relationships. In this example, each student could be in many classes and each class could have many students. Breaking down this requires adding a 'join table'. Perhaps an enrollment table? Each student can enroll to many...