Click here to Skip to main content
15,891,777 members
Everything / Database Development / SQL Server / SQL Server 2008

SQL Server 2008

SQL-Server-2008

Great Reads

by Wonde Tadesse
This tip/trick helps to set a default value for blob data type such as Image, VarBinary.
by Mubin M. Shaikh
Create time dimension with 24 hour plus values and time buckets in your data warehouse
by Harmen Brouwer
How to create and deploy a SSRS rendering extension, explained by a functional Zip Rendering extension for SSRS 2005, 2008 (R2) and 2012.
by Tecfield
This tip shows how to rename a database and its MDF and LDF files in SQL Server.

Latest Articles

by Mubin M. Shaikh
Walkthrough of the process for one of the industry best practices to export all SQL tables in Flat file format
by Alaa Ben Fatma
Explore your MMSQL server tables in a professional way
by Mahsa Hassankashi
Best approach for having more secure channel to transfer user information throughout the web
by Mahsa Hassankashi
This article enables you to generate table in any database such as Oracle, SQLServer, MySQL, SQLite, Sybase, etc. just by typing table name and its fields. Then you can use NHibernate facilities to make query for data layer.

All Articles

Sort by Updated

SQL Server 2008 

19 Apr 2024 by Member 16247227
dateadd(day,1,eomonth(dateadd(month,-1,convert(date,getdate()))))
28 Mar 2023 by Saral S Stalin
Hi experts,As per my understanding NUMERIC(18, 10) column would take 18 decimal digits to the left of the decimal point and 10 to the right. One of our procedure started throwing 'Arithmetic overflow error converting numeric to data type numeric' error for much lesser values. I checked...
28 Mar 2023 by Member 15964288
Hi, NUMERIC(18, 10) doesent have 18+10 digits, that anotation means that you have 18 digits and 10 of those are on the decimal places. If you want 18 unit digits and 10 decimal digits you declare this way: NUMERIC(28,10)
5 Jan 2023 by Boopalslm
This is my query How to reset invoice number at the beginning of the financial year using SQL server 2008 This is my query select isnull(max(billnu),0) +1 from sales where saldate between CAST('04/01/'+ CAST(YEAR(GETDATE())as varchar) as...
5 Jan 2023 by CHill60
Assuming you are going to include the Year as part of the "final" invoice number and the number you are trying to reset is just the "number of invoices so far this year" then have a look at the solution at Invoice no should starting with 1 for...
5 Jan 2023 by OriginalGriff
Ermmm ... are you sure? Most accountants and tax men frown on reusing invoice numbers as it leaves space for error or fraud: two identical invoice numbers with different companies and values on them raise some real red flags, as do "unexplained...
20 Dec 2022 by Member 15870843
create table Data (Name varchar(50)) insert into Data values ('siva') insert into Data values ('Ram') create table data_value(letter varchar(50),value int) Insert into data_value(letter,value) values('a',1) Insert into data_value(letter,value)...
20 Dec 2022 by kirthiga S
Hi All,I want to split a word into letters and assign value to each letter and need the sum of assigned values.For Examplecreate table Data (Name varchar(50))insert into Data values ('siva')insert into Data values ('Ram')select * from DataIf i assign value to...
25 Oct 2022 by Member-9697757
Hi friends,We have planed to merge Database, for that we prepared packages using Data Flow Task for transferring records from our Base DB to Merge DB.We prepared packages in different machines. Now we tried to consolidate all the packages(there are 9 packages each pack contains more than...
25 Oct 2022 by Member 15809297
If you will load a ssis package from a SQL Server, under a proxy account, be sure to grant to that user db_ssisoperator on msdb database.
22 Aug 2022 by shriti 3
Conversion failed when converting from a character string to uniqueidentifier.How to handle this error
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...
23 Feb 2022 by lovejeet0707
How can I display the message every time a new message is received. If new Feedback is received, then it should show that new feedback is there. Actually, Feedback in my application is coming from Employees to Admin and Vice Versa for admin. Can...
22 Feb 2022 by _Asif_
This is possible in a number of ways. Try this GitHub - dyatchenko/ServiceBrokerListener: Component which receives SQL Server table changes into your .net code.[^] Have fun
20 Feb 2022 by Maciej Los
Sorry, but your SQL code is very hard to understand... I also do not understand why the desired result contains this record: ABC1222 1/30/2022 You have defined @StartDate date ='2022-02-01', which should eliminate this record from output. If i...
20 Feb 2022 by akhter86
Below is my data CREATE TABLE #Containerno(CID INT,Contno VARCHAR(50),ConWeight nvarchar(50),Entrydate date ,DelID int,cat_ID int) CREATE TABLE #ConIssuance (IID INT,CID INT,QTY INT,IWeight int,Entrydate DATETIME,DelID int) ...
13 Feb 2022 by Muhammad Esa
the first sub-query return data repeatedly SELECT * FROM (SELECT TOP (100) PERCENT dbo.subjects.Dsubject AS 'Dsubject1', dbo.RESULT.TOTAL AS 'TOTAL1', dbo.RESULT.SEMESTER AS 'SEMESTER1', dbo.RESULT.TotalCreditMark AS...
13 Feb 2022 by _Asif_
Your query does not make sense because it is showing a group of subject, semester missing studen info all togather. i think the same could be acheived in a much simpler way. Food for thought: SELECT TOP (100) PERCENT dbo.Student.Regno,...
12 Feb 2022 by M Imran Ansari
OUTER APPLY work as LEFT OUTER JOIN on tables. In your query you have two different queries and there is no join between them. To match the records with second query you need to check on the basis on both result sets column. like second query...
31 Jan 2022 by kparun86
IngredientName NUTRIENTNAME NV...
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
29 Dec 2021 by Nirmala Saravanan
hi all I am using SQL server 2008 I have a string with delimiter full stop(.). I want to separate string in the next line to display in the Crystal report string is like str ='aaaaaaaaaaaaaa.bbbbbbbbbbbbb.cccccccccccccc.ddddddddddddddd' ...
29 Dec 2021 by Maciej Los
In a newer version of SQL Server you can use STRING_SPLIT (Transact-SQL) - SQL Server | Microsoft Docs[^]. For older version of SQL Server, you need to create custom function (for example: Converting comma separated data in a column to rows for...
28 Dec 2021 by Wendelius
Depending on where you want to use the text the newline may vary. In Windows the newline is using two characters; Carriage return and line feed. In order to replace dots with cr+lf have a try with DECLARE @strInput nVARCHAR(Max), @strResult...
29 Nov 2021 by adhikar patil
Hello All, I have following table structure with more than 10 lakh records and i want to find out MAX Rainfall by every day with group by AWS_Id and AddeedOn as Date. I have tried but gives me error like Execution Timeout Expired. The timeout...
29 Nov 2021 by Richard Deeming
Quote: cast(AddedOn as date) between DATEADD(DD, -1, '2021/01/01') AND '2021/11/10' That's a likely problem - calling a function on a column in your WHERE clause will make the query non-SARGable. Instead, use: AddedOn >= '20201231' And...
24 Jul 2021 by AEmu1 DD
I'm making a student enrollment system using visual studio 2019 and SQL server management studio 2008.When I clicked the insert button,'Inserted Successfully',there's no error also when i click the registration button,'Record Updated...
24 Jul 2021 by OriginalGriff
That's some odd code - there are a lot of things wrong there, not the least being that you show an "Inserted correctly!" message before you even try to do the INSERT Then when you do the insert, you follow it with a ExecuteReader - and discard...
12 Jul 2021 by Hamid Noahdi
I have a win form application coded in c# 2010.The server is in somewhere else and has a IP Valid(SQL Server 2008 enterprise edition).When the application is idle for about 45 seconds, after a request i have the exception...
14 Jun 2021 by ahmed_sa
I run query below it take too much time it reach to 30 minue so I need enhance it to get 5 minute or 10 minute at maximum if less it is good this is my execution plan as below : https://www.brentozar.com/pastetheplan/?id=ryIvvs4od this is my...
14 Jun 2021 by Wendelius
Few things to consider based on the script the original tables have no indexes, why? You should index the columns you use to join tables you have no foreign keys defined. I take it the id columns still reference other tables. First of all,...
20 Jul 2020 by IviKAZAZI
Hello everyone,I am executing a Sql Server 2008 query which returns a set of rows. When i execute the same query from code, using SqlDataReader ,reader.Read() returns null. Any ideas??The query is a simple Select Statement,with two declared variables which are used in Where...
14 Jul 2020 by Mubin M. Shaikh
Walkthrough of the process for one of the industry best practices to export all SQL tables in Flat file format
9 Jun 2020 by pwavell
Can we Pass table valued parameters and normal params like integer,varchar etc..to a single stored procedure?If we can then how to pass them? I currently have the followingALTER PROCEDURE InsertData( @slno nvarchar(255), @OrderNo nvarchar(255), @M3 M3...
29 May 2020 by vahid_erad
hi freindsi have a table with 250 record , i want select 100th to 200th rows , please guide me.
7 May 2020 by Jassom
Hello there.. I have a stored procedure that I am using to store varbinary data, so if the file is small almost 50mb to 150mb it works fine, but the problem when I try to store bigger than 300 mb, it doesn't work and shows message says: Quote: ...
5 May 2020 by phil.o
Usually, it is not recommended to store files, especially large ones, in your database. Databases are not optimized to store huge binary files. Instead, you shoud store the path to the file in the database, and leave the file itself to 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...
25 Mar 2020 by a1mimo
Hello All,My problem is simple I have a birthdate column of type date in my sql database and in my application I use dateTimePicker to get the birthdate, but when trying to insert the date I got from the dateTimePicker I get an error Incorrect syntax near '12'And when I try to debug the...
1 Dec 2019 by gani7787
Ho to concatenate two columns in SQL Server 2008.Example Below-------------ID(int) Year(int) ------- ---------10 200820 200930 2010Output should come as belowID_Year (Output)-------10-200820-200930-2010How to query in...
1 Dec 2019 by Member 14675097
select ID || '-' || Year as ID_Year from tablename
22 Nov 2019 by Member 12456202
i got this error and i don't know how to solve this.....did research but failed to get an appropriate answer.....this is my first post...sorry for my bad language Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click cnnOLEDB =...
22 Nov 2019 by Member 14665388
1014:SUB-AUA code is invalid" to type 'Integer' is not valid.Aadhaar Service
22 Nov 2019 by SatyaKeerthi15
CREATE ASSEMBLY failed because it could not open the physical file (The device is not readyCREATE ASSEMBLY ROCEventHandlerAUTHORIZATION dboFROM 'C:\WINDOWS\assembly\a.dll'WITH PERMISSION_SET = SAFEGO
22 Nov 2019 by Cheap Old Bastard
make sure that the windows user mssqlserver has at least read access to the dll
14 Nov 2019 by Member 14655569
Please just check the web service url you're pointing to. I deployed an SSRS on two separate server and one worked fine while the other threw this error "the request failed with http status 401 unauthorized." So after a few hours I saw saw that I wasn't pointing to the web service url on my...
2 Nov 2019 by Alaa Ben Fatma
Explore your MMSQL server tables in a professional way
2 Oct 2019 by krunal25
Hello everyone,I have two machines which are connected with LAN and i have SQL-2008 on both machine and i have linked both the SQL server by using this stored procedureExec sp_addlinkedserver@servername = 'CMSSERVER\SQLEXPRESS',@srvproduct='SQLServer OLEDB...
18 Sep 2019 by mona shalaby
hi alli have stored which one of its parameter is in Arabic, i have a problem in entering this parameter like below @Grade nvarchar(50)asbegindeclare @s nvarchar(50) set @s= N "'+@Grade+'" print @sthe result is '@Grade', So how could i input it in the correct format
16 Sep 2019 by Member 7932936
we insert the word files in database in varbinary format.Now we want to retrieve the word files then we are converting the varbinary format to string.Here we are using the code:-string x = Encoding.ASCII.GetString(buffer).ToLower();It is working for .doc files only.when we retrieve...
14 Aug 2019 by Muzammil Burhan
USE TESTGO/****** BULK INSERT ******/BULKINSERT [test]FROM 'C:\emp.csv'WITH(FIRSTROW = 1,FIELDTERMINATOR = '|',ROWTERMINATOR = '\n')GO/****** End ******/Msg 4864, Level 16, State 1, Line 3Bulk load data conversion error (type mismatch or invalid character for...
14 Aug 2019 by shaker133
Hi Dear the problem in the file coding 'text file ' the default coding is ANSI change it to unicode and save it, Thanks. ENG. Shaker.
6 Aug 2019 by kirthiga S
Hi,Im having a table with Places Name seperated by a delimiter.I want to split the Places name Seperately based on delimiter.How to achieve this using a query?Example:create table #place(Places varchar(100))insert into #place values('Chennai, Banglore, Mumbai,...
30 Jul 2019 by Subodh Gaur
Query: - exec sp_rename 'new_tblencounter.encounter','encounter_dates','COLUMN' ; It's Works.
30 Jul 2019 by Unareshraju
hi all, i am trying to change column name in sql2008 from StudentId to SID .i am using this query :alter table Studentrename column StudentId to SIDBy using this not altered the table column .so that please any one help to me.thanks in advance regarding ,naresh
5 May 2019 by Supriya Srivastav
Dear All,I have to insert (,) in a field in table in sqlserver through C# code,how can I do so?Please help.Thanks in advance,Supriya
5 May 2019 by Haramshahi
in windows character map font Consolas use char U+201A and its look like comma . and inserted in sql database by query Ꞌ
3 Apr 2019 by Mahsa Hassankashi
Best approach for having more secure channel to transfer user information throughout the web
3 Apr 2019 by Mahsa Hassankashi
This article enables you to generate table in any database such as Oracle, SQLServer, MySQL, SQLite, Sybase, etc. just by typing table name and its fields. Then you can use NHibernate facilities to make query for data layer.
15 Mar 2019 by pranathis012
Hi,This works fineSELECT DISTINCT SED.MCSED_SED_Short_Description, SCH.Doc_SNo, FROM @Schedule_Status SCH , DMS_M_Company_Schedule_Element_Details SED WHERE SED.MCSED_SED_Code =123 ORDER BY SED.MCSED_SED_Short_Description, SCH.Doc_SNo, SCH.Doc_NoBut when i introduce case...
15 Mar 2019 by Member 10229842
SELECT DISTINCT SED.MCSED_SED_Short_Description, SCH.Doc_SNo, ord = CASE SED.MCSED_SED_Short_Description WHEN 'VD' THEN 1 ELSE 2 END, SCH.Doc_No FROM @Schedule_Status SCH , DMS_M_Company_Schedule_Element_Details SED WHERE SED.MCSED_SED_Code =123 ORDER BY CASE...
5 Nov 2018 by Member 7932936
HiHow to assign null value to date? By default my datetime is 1/1/0001, but I want to assign datetime to null. How can I assign null value to datetime? I tried by this code but it is not working. dt = Convert.ToDateTime(strposteddate); strposteddate =...
24 Oct 2018 by Joy1979
Hello Friends!!I have window Form with 'text box' for display and 'command button' to find customer number.Can you please help me how to perform search command in Vb.net?Im using SQL Server 2008r2 as my Database.... i Can now Connect to my Database, and insert some of my records with...
28 Sep 2018 by User 11060979
Have a look here: CREATE SEQUENCE (Transact-SQL) | Microsoft Docs[^] You can read that SEQUENCES APPLIES TO: SQL Server (starting with 2012). In case you like to use sequences (what is a really good idea from my Point of view) you Need to upgrade at least to 2012.
28 Sep 2018 by rayson tom
I am not able to create sequence in sql 2008 CREATE SEQUENCE [dbo].[NewCounter] AS INT START WITH 5 INCREMENT BY 5 Msg 343, Level 15, State 1, Line 1 Unknown object type 'SEQUENCE' used in a CREATE, DROP, or ALTER statement. What I have tried: tried searching the system db objects but...
22 May 2018 by Member 13423065
May be you could try using SQLPACKAGE.exe and create batch files (.bat) and run them as executable
22 May 2018 by Shanalal Kasim
Hi all,Please help me out to solve this issue.Is there any way to convert more than one .sql file to .exe/Executable file .In our application, we are using more than 400 tables and more than 500 sp's. while releasing time, currently we are giving each sp / table / view / etc are...
8 May 2018 by Thomas Daniels
If you use Visual Studio, you can try right-clicking on "SystemFunction" and see what it suggests; perhaps you are missing a using ...; at the top of your file. If that's not the case, then check that your application has all the necessary references to external libraries, because SystemFunction...
8 May 2018 by harristars
Line 63: price = (decimal)tbl.Rows[i]["SalePrice"]; Line 64: quantity = (decimal)tbl.Rows[i]["SaleQuantity"]; Line 65: SystemFunction.GetProductInfo(id, out code, out name, out module, out color); Line 66: DataRow dr = AddNewRow(dt,...
13 Apr 2018 by AYDIN_CANDAN
hi. here is solved your problem.. DataClasses2DataContext db = new DataClasses2DataContext(); IEnumerable sp_gelen = (IEnumerable)db.sp_SonYapilanlar(); List listemeARTI = new...
13 Apr 2018 by sunandandutt
Hi Team,Here I got issue while fetching data from dynamic created procedure in linq.it returns 0Procedure is created with the help of Pivot data from existing table.Here is Stored Procedure.ALTER proc [dbo].[usp_tblProperty]ASDECLARE @PivotColumnHeaders VARCHAR(MAX)SELECT...
2 Feb 2018 by Luca Astolfi
User defined procedure for make an HTML table from T-SQL Select statment
21 Jan 2018 by ankit.agg1984
Hello,How to insert,Update and Delete data using datagridview in c# .net windows application?It should be recede or rearrange ID or Sr. No. after delete any row.How it can be possible?Please help me.Thanks in Advance RegardsAnkit AgarwalSoftware Engineer
10 Jan 2018 by Amir Jalilifard
In this article, you are going to learn about P2P Network and Windows Communication Foundation to share your files between peers through a P2P network.
11 Dec 2017 by Ravimcts
In my ERP the deadlock occurs, so many times , due to which my 200 employes in my company was not able to do their work. I am 1.3 yr Dot Net Developer, i dont have so much knowledge about the SERVER and these problem but through Google i found some solution, but still i cant get any success.i...
7 Nov 2017 by OriginalGriff
You are rapidly becoming a Help Vampire: and will fail your exams if you do not start doing your own homework very soon. We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor...
5 Oct 2017 by tolgasenol
hi all,actually topic tells the problem. details are;i have a datagridview in windows forms which has data from an sql table. i've inserted checkboxes with DataGridViewCheckBoxColumn. I need to check one or multiple checkboxes(rows) to update selected rowS. there is a column which...
22 Sep 2017 by #realJSOP
It doesn't always happen the way you expect.
26 Aug 2017 by amritbdk
siri want to insert into a table through storeprocedure if a composite primary key is present having 3 attribute,if i have insert 3 same int type no into table it is raising a error,how to handle the error pls help me
26 Aug 2017 by Member 13379370
If you have composite key and want to insert values into it. Then try below code insert ignore into HotelBooking(RoomID, RegisterDate , CustomerName , Gender , Address , BillAmount ) values ('R1002', '12/12/2018','Adam Ponting','Male', 'Sydney Australia' , '1132.11') ON DUPLICATE KEY UPDATE...
7 Aug 2017 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!
2 Aug 2017 by mohammad ehsan
Hi.i wanted to know what is difference between Stored procedure & function in SqlServer ?and where each one is used in ?for example i have just written a stored procedure and i have finished it with return @@Identity so can we say is this a fucntion because this will return a value ?...
8 Jun 2017 by Madhusudhan H N
extracting .mdf file and .ldf file from .bak
2 Jun 2017 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
1 Jun 2017 by AhsanAhmed
A brief introduction on how to use FOR XML clause in EXPLICIT mode in Microsoft SQL Server to return data in XML format
9 May 2017 by abdul wahab.o
After converting my WPF(C#) project from VS2008 to VS2010 everything is working fine without rdlc report.I got the following error while running my reportMicrosoft.Reporting.WinForms.LocalProcessingException was caughtMessage=An error occurred during local report...
14 Apr 2017 by Member 12955507
I am trying to import the .DAT database to SQL server 2008. Then error occurred. What I have tried: How can I solve this error and Successfully import the database ? [^]
14 Apr 2017 by Dave Kreskowiak
You can't. You're trying to restore a backup from a newer version of SQL Server to an older version. That's not going to work. You have no choice but to either upgrade the SQL Server version on the machine you're trying to restore to or build a new SQL Server with the same version the backup...
20 Mar 2017 by anjankant
I am working on web application. Suddenly i got the error "System.Data.SqlClient.SqlException was unhandled by user code: Login failed for user 'IIS APPPOOL\DefaultAppPool". Can anybody help.
2 Mar 2017 by Abhilash.J.A
I am using this SQL query,("SELECT (month(bill_date) & ', ' & year(bill_date)) AS dt, " & _"count(1) AS nbills, sum(amount) AS tamt, sum(iif(chk_free=1,amount,0)) AS pamt, " & _"tamt-pamt AS totamt From rec_all Where iif(rec_ref is null,0,rec_ref)1 and rw = 0 and bill_date " &...
2 Mar 2017 by Bryian Tan
1. The & inside the "SELECT ... " should be +2. You might also need to convert the month and year into varchar to avoid the error "Conversion failed when converting the varchar value '3, ' to data type int."Example: SELECT CONVERT(VARCHAR(2),MONTH(bill_date)) +', ' +...
23 Feb 2017 by Pete O'Hanlon
As Dave said, you would have to use JavaScript. Theoretically, when your page has loaded you could hook into all the relevant tags and add an event listener to each one (hint JavaScript provides an addEventListener that you would need to use). There are restrictions with this approach though,...
23 Feb 2017 by chetna2810
I want to track all activity of registered user (user already created a account in web application) on a webpage like where he clicked (not a postback event used onclick of anchor), what text he searched (like filter of records etc), how much time spend on a webpage without using any third party...
21 Feb 2017 by Dave Kreskowiak
Yeah, you can't do this from C# code. ASP.NET code runs ENTIRELY server-side. It has absolutely no access to the client at all.If you're looking for stuff like where on the page a user clicked you MUST use client-side scripting to do it and send that information however you want to whatever...
10 Feb 2017 by resht
I have one att table , it has two columns EmployeeId and Date.EmployeeId | Date 10214 | 2017-01-02 08:16:00.00010215 | 2017-01-02 08:17:00.00010170 | 2017-01-02 08:45:00.00090 | 2017-01-02 09:20:00.000202 | 2017-01-02 09:38:00.000125 | 2017-01-02 09:40:00.000163 |...
10 Feb 2017 by OriginalGriff
See here: SQL GROUP By and the "Column 'name' is invalid in the select list because..." error[^]