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 

7 Jan 2010 by #realJSOP
It would help if you gave us the output you're seeing.
8 Jan 2010 by #realJSOP
The first thing I would do is evaluate the string in the debugger BEFORE it's sent to your stored procedure. At that point, you can paste it into SQL Manager Express and try the query there to see WHERE your problem is.
21 Jan 2010 by #realJSOP
USE THE DEBUGGER.It would have allowed you to discover that there is only one item in the rdr object. Using a value greater than 0 will almost always result in an exception.
30 Jan 2010 by #realJSOP
You know, your coding would go A LOT faster if you used google:http://msdn.microsoft.com/en-us/library/ms186724.aspx[^]
30 Jan 2010 by #realJSOP
Why don't you just include a nag screen if it's not registered. Have the nag screen come up every 5 minutes or whenever a major feature is used.Don't forget to obfuscate your code with a COMMERCIAL obfuscation tool. Don't use the one that comes with VS2008 because it can easily be reverse...
15 Feb 2010 by #realJSOP
Just implement authentication on the page. If this group of users never changes (or infrequently changes) I would consider creating a group on the web server, give those users an account on the box, and put them into the group that is allowed to access the web app. That way, the we app can ask...
22 Mar 2010 by #realJSOP
Imagine... If you had googled this (like I did), you wouldn't have had to wait for an answer...The following line will tell you the last identity that was entered into the specified table.SELECT IDENT_CURRENT(‘tablename’)
6 May 2010 by #realJSOP
Do it like this:filename = filename.Replace(" ", "");...but if the filename on the disk actually includes the spaces in the name, you won't be able to find it later when you retrieve the name from the DB...
8 May 2010 by #realJSOP
I googled the error message (and you can too - really!):Here's the first of many hits.http://geekswithblogs.net/AzamSharp/archive/2005/07/27/48416.aspx[^]
9 May 2010 by #realJSOP
You could 0) script the creation of the database to a file1) attach that file to your application as a resource2) each time your program starts (after being installed), it can check to see if the database is installed 3) if not, extract the script from the resources and run it on...
17 May 2010 by #realJSOP
Well then, the obvious answer is that you're doing something wrong in the web page. Are your parameters (if any) correct? Are you calling the correct stored procedure? How are you calling the stored proc from the web page? What exception is being returned?Your question is so vague that we...
25 Jun 2010 by #realJSOP
You have to look for patterns in the data. Right now, it looks like all of the strings returned that have the date in them start with "BTH", and end with a string of seven numbers. You could parse them based on that.string x = "BTH2010124";string prefix = x.Substring(0,3);string...
25 Jun 2010 by #realJSOP
Based on your comment to my reply:If the date is always at the end, you could reverse the string retrive the non-date portion, and then reverse it back:string x = "ABCDEFG2010124";string prefix = x.Substring(0,x.Length - 7);string possibleDate = x.Substring(prefix.Length-1, 7);if...
10 Aug 2010 by #realJSOP
You've already identified the solution - create a windows service. Go forth and code.
10 Sep 2010 by #realJSOP
The just set it in that stored proc (don't forget to set it to off before the stored proc exits).
16 Sep 2010 by #realJSOP
Well, all of the software you're trying to install or use is compatible with SP2. Since there appears to be a problem, change your minimum requirement o includ XP/SP3 and you're golden.Anyone running XP should be running SP3 anyway.
25 Oct 2010 by #realJSOP
A simple google search ("scheduling tasks in sql server") reveals over 300 THIOUSAND results, among which, was this one:http://msdn.microsoft.com/en-us/library/ms191439.aspx[^]
2 Nov 2010 by #realJSOP
A little google goes a long way ("t-sql get date from datetime") - I found at least three ways to do it, and that was at the first link returned by google. Here's one of them:SELECT CONVERT(CHAR(10),GETDATE(),103)
5 Dec 2010 by #realJSOP
0) This question is unanswerable, other than to recommend that you hire a programmer.1) Don't use your email address as a user ID. It's beyond stupid...
17 Dec 2010 by #realJSOP
Yes, it should do the same thing, but you could have determined that yourself by simply running the two different query versions in SQL Server Management Studio Express...
27 Dec 2010 by #realJSOP
This link describes how to estimate the size of an entire table, but it starts out by estimating the size of a single row:http://msdn.microsoft.com/en-us/library/aa933068%28v=sql.80%29.aspx[^]Google really is that easy to use...
3 Jan 2011 by #realJSOP
This question cannot possibly be answered here (in Questions & Answers) because the topic its too broad, and a variety of opinions can be expressed. Repost it in the appropriate forum so you can have a threaded discussion about it, or limber up your google muscle and research this thing yourself.
3 Jan 2011 by #realJSOP
I found this with google:http://mathworld.wolfram.com/XOR.html[^]
3 Jan 2011 by #realJSOP
You need to specify an OUTPUT parameter in your stored procedure parameter list, and set its value in the stored procedure.Use google to find an appropriate example for your needs. I recommend the search phrase "t-sql return value from stored procedure", or "t-sql set variable based on query".
8 Jan 2011 by #realJSOP
I'm not a DBA, nor really that skilled in it, but this is the way I'd approach it. For parts you need to research, google is definitely your friend:0) Create a temporary table with all of the months in it - call it TEMP_YEARS.Null 0 1NULL 0 2NULL 0 3..NULL 0 121) Create a...
10 Jan 2011 by #realJSOP
It's supposed to increase performance on a SQL query that otherwsie doesn't have any conditions. It also allows you to build dynamic queries because with the WHERE 1=1 at the end of your query, all you have to add is AND clauses for your actual conditions.
12 Jan 2011 by #realJSOP
If it were me, I'd do it in multiple queries, and store each result in its own variable. That would also make the sql more maintainable, and maybe even faster than trying to wrangle all that into a single query.
17 Jan 2011 by #realJSOP
There's nothing built in, but this CodeProject article may help:Audit Trail Generator for Microsoft SQL[^]
21 Jan 2011 by #realJSOP
google "t-sql convert var char to datetime" for more info, but basically, it goes something like this (your needs will most likely be different):CONVERT(DATETIME, SUBSTRING(datefld,5,4)+SUBSTRING( datefld,1,4),112)
20 Mar 2011 by #realJSOP
If he wants a richer application, and you want something web based, it seems like Silverlight would be the perfect fit.Other than that, use SQL Server 2008 instead of 2005 (it's more secure and more closely tied in to reporting services), put the database server on a separate box, and use a...
11 Apr 2011 by #realJSOP
AML file is "ARC Macro Language".Google is your friend.
14 Apr 2011 by #realJSOP
Do you mean from the sql side of things or the application side? You gotta be a lot more specific. And what do you mean by "orphaned" connections? As far as a .Net application goes, you should ALWAYS close a connection after using it. There are few reasons to keep a database connection open...
28 Apr 2011 by #realJSOP
You can only make a background image fit the browser window. You can do this with the css style body{ background-img:url(myimage.jpg); background-size:cover;}If you google "css background image", you'll find a lot of other stuff about how to work with it.EDIT...
3 May 2011 by #realJSOP
select dbo.MyFunctionName(@param1..)
4 May 2011 by #realJSOP
I would use PlaceHolder objects, making the lowest-security one always visible, and then making the higher security ones visible based on the user's role. Of course, this is over simplifying the whole thing, but I think you get the picture.
4 May 2011 by #realJSOP
I googled "update sql database from excel", and it came up with over 6.3 million results. The very frist one looks like it might be applicable, but since I have no emotional interest in the solution, I'll leave it to your capable hands to sift through the possibilities presented by google and...
16 May 2011 by #realJSOP
You don't "switch between layers". The layers are intended to abstract those functional parts out from each other.
23 May 2011 by #realJSOP
SELECT SYSDATETIMEOFFSET()Google reveals all...
3 Jun 2011 by #realJSOP
You can do this:exec(@sql)or this:exec sp_executesql @sql
27 Jun 2011 by #realJSOP
insert blah into Employee; insert blah into Order; Notice the semi-colon separating the two statementes. It's "technically" two queries, but you can run them both with a single call to SqlCommand.ExecuteNonQuery().
1 Jul 2011 by #realJSOP
If your table is configured correctly, the unique identifier will automatically increment - all you have to do is add the rows.As to your problem, I would do it this way (psuedo-code follows):open filecreate/open connectioncreate command objectwhile you have records{ set the...
7 Jul 2011 by #realJSOP
I'm no sql expert, but I think this might work (or at least set you on the right track):CASE UPPER(FixedOrPower) WHEN 'POWER' THEN CASE CHARINDEX('.', RTRIM(STR(Diopter)) WHEN 0 THEN RTRIM(STR(Diopter)) + '.0D' ELSE...
11 Jul 2011 by #realJSOP
Well, it looks to me like the error pretty much tells you what's wrong. Check your connection string and make sure it's correct, and:Is the remote machine turned on?Is SQL Server installed on the remote machine?Is SQL Server configured to allow remote connections?As far as the...
28 Jul 2011 by #realJSOP
Don't include anything more than what is required to accomplish the process. That's one of the biggest problems with apps and web sites - they try to add useless bells/whistles that have no impact on the underlying process other than to elicit the "gee-whiz" response pattern.It sounds like...
30 Jul 2011 by #realJSOP
Try this:SELECT * FROM Sample WHERE DATEDIFF(DAY, StartDate, GETDATE()) = 15
1 Aug 2011 by #realJSOP
Is the server itself working? Can you ping the box?
10 Aug 2011 by #realJSOP
You can't install the 32-bit version of SQL Server on a 64-bit OS (and vice-versa).
12 Aug 2011 by #realJSOP
Electronic Medical Record?Electronic Message Routing?What does EMR mean in your context?
26 Aug 2011 by #realJSOP
Store it as a single string. The linefeeds will remain as part of the data. You shouldn't need sample code.
8 Sep 2011 by #realJSOP
I'm not a sql expert, but what you want to investigate the following t-sql commands:COALESCEPIVOTThe PIVOT command will arrange the data the way you want it, and the COALESCE command will help you put the resulting dataset into a comma-delimited string.Google is your friend.
13 Sep 2011 by #realJSOP
Instead of doing it in your SQL, do it in your application code by checking the DataTable.Columns.Count property.
7 Nov 2011 by #realJSOP
Google reveals all:http://support.microsoft.com/kb/213841[^]
8 Dec 2011 by #realJSOP
Assuming you've implemented an appropriate level of exception handling which isn't showing you where the problem might be...Write diagnostic info to the system log (or a text file). This is going to take a while because unless you have an idea of where/why it's breaking, you're doing to have...
16 Dec 2011 by #realJSOP
Create a temporary table that contains the search words, and then do a join on the table/column(s) you're searching.
24 Feb 2012 by #realJSOP
Either create a new script task that appends the desired data to the database after the data is imported, or assuming the task that performs the import calls a stored proc, have the stored proc append the additional data.
29 Feb 2012 by #realJSOP
Writing a SSIS package is the perfect solution for this. BTW, SSIS in Sql Server 2005 requires VB.Net, but that shouldn't be a problem - VB is the same as C#, only different.
9 Mar 2012 by #realJSOP
You cave to set the identifier as an integer type, and then set the Identity Specification property of the field (use the designer in sql server manager) to "YES".Then, whenever you do an insert, it will auto-increment the field.
13 Mar 2012 by #realJSOP
If they're strings, you have to parse out the month and year using the SUBSTRING function. When you do that, you can create a new DateTime variable which can then be used with either the DATEDIFF function (to find the difference between the two dates), or the BETWEEN function (to see if another...
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).
3 Jan 2013 by $*Developer - Vaibhav*$
cmd.CommandText = " Select * From GetUsersID";cmd.Connection = conn;conn.Open();DataTable dt = new DataTable();dt.Load(cmd.ExecuteReader());conn.Close();DropDownList1.DataSource = dt;DropDownList1.DataTextField = "Name";DropDownList1.DataValueField = "ID";DropDownList1.DataBind();
3 Jan 2013 by $*Developer - Vaibhav*$
First - Bind the dropdown on page_load event.SqlCommand cmd = default(SqlCommand);SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString);con.Open();cmd = new SqlCommand("Select * from Call_Reg where...
24 Feb 2013 by $ultaNn
i want my id as output when i submit the record i want to see the ID of that record i m trying this i am not getting any thing ALTER PROCEDURE [dbo].[Tech_sup] ( @Build_name varchar(max), @Dept varchar(max), @Floor_no varchar(50), @Call_recvd varchar...
3 Jun 2013 by $ultaNn
I Have four table Order_RequestTbl_PrinterTbl_MonitorTbl_CPUI have a relation FK_Tbl_Order_Request_Tbl_CPU and FK_Tbl_Order_Request_Tbl_Monitor FK_Tbl_Order_Request_Tbl_Printerwhen i try to enter data for moniter in Order_Request its giving me error The INSERT statement...
23 Jul 2013 by $ultaNn
i have two table Tbl_Device and Tbl_ReceivedQtyI want the sum of record with inner join Device i tried to join with this query but failed SELECT Tbl_Device.Device_Name, Tbl_ReceivedQty.Qty_Device_ID, Tbl_ReceivedQty.Qty_User, Tbl_ReceivedQty.Qty_Date FROM Tbl_Device...
14 Dec 2014 by /\jmot
What about..using.http://msdn.microsoft.com/en-in/library/ms186734.aspx[^]andhttp://technet.microsoft.com/en-us/library/gg699618(v=sql.110).aspx[^]
10 Jul 2010 by /randz
I do not think calling stored procedure in a function is possible. It's either you modify the stored procedure to be a function, or modify the function to be a stored procedure.I your case, you may convert your the stored procedure into a function so that it can be called inside the...
16 Nov 2010 by 118Rahul
how to create Remote service binding
6 Jan 2011 by 161911
Hi,I cannot connect to [servername]Information: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 the instance nameis correct and that sql server is configured to allow remote...
19 Oct 2011 by 2011999
Dear Experts, SQL Server Database in ZIP file how to fetch the databases in SQL Server Existing databases.Thank you for valuable replay.
20 Oct 2011 by 2011999
Dear All Experts,How to configure SQL Server instances please send me related links and PDF Files.Thanks for your valuable replay
23 Oct 2011 by 2011999
Dear all Experts,Through using grid view in VS2010 and SQL server 2008 Back End how to generate the Reports. I need Cristal ReportsThank you for your valuable replay.
21 Oct 2011 by 2011999
Dear All Experts, connectionString="Data Source=.\SQLEXPRESS; database=Northwind;Integrated Security=true"/> But anable to connect my databse. What i will do nextThank u for ur valuable replay
23 Oct 2011 by 2011999
Dear All Experts,I was created menu using (Java & HTML) Scripts in my menu new,open is in menu itemswhenever click the open, directly go to the Sql Server create open dialog. how to write the code using c# (asp.net).Thank u for valuable replay.
25 Oct 2011 by 2011999
Dear All Experts,I need code for Login and logout, sending details of website (in asp.net) please help me how to start procedure. if posible code send me my email id xxxxxxxx@gmail.comThaks in advance your valuable reply.
1 Nov 2011 by 2011999
ExecuteReader: Connection property has not been initialized.Near the i got Error SqlDataReader dr = cmd.ExecuteReader();Thank u for valuable replay
5 Nov 2011 by 2011999
if (!IsPostBack) { con.Open(); cmd.Connection = con; for (j = 0; j
8 Nov 2011 by 2011999
Compiler Error Message: CS1061: Source Error:Line 34: Line 35: TotalMarks:Line 36: Line 37: Line 38: i got error...
9 Nov 2011 by 2011999
Dear All Expertsstring query = "update Questionnaire_UserAnswers set Comments='" + (TextBox)grdView.Rows[0].Cells[e.index].Controls[0] + "', Marks=" + (TextBox)grdView.Rows[4].Cells[e.index].Controls[0] + " where Question_ID=" + (TextBox)grdView.Rows[0].Cells[e.index].Controls[0] +...
9 Nov 2011 by 2011999
Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index string query = "update Questionnaire_UserAnswers set Comments='" + grdView.Rows[].Cells[1].Controls[0] + "', Marks=" + grdView.Rows[4].Cells[5].Controls[0] + " where Question_ID=" +...
18 Nov 2011 by 2011999
Label l = default(Label); l = (Label)v.FindControl("Label1"); l.Text = dt.Rows[ctr]["Serial"] + ","; l = (Label)v.FindControl("Label2"); dt.Rows[ctr]["question"] = l.Text;I got error l.Text = dt.Rows[ctr]["Serial"] + ","; in this line there is no position at row. ...
19 Nov 2011 by 2011999
partial class Default2 : System.Web.UI.Page{ int i; //int count =0; string ans= null; int[] a=new int[5]; int t=0; SqlDataAdapter adp= new SqlDataAdapter(); DataSet ds = new DataSet(); int ctr = 0; SqlConnection con = new SqlConnection("Data...
20 Nov 2011 by 2011999
Dear Experts, private int GetRandomNumber(int[] levelIds) { bool exists = false; int randomIndex = 0; do { Random rand = new Random(); randomIndex = rand.Next(levelIds.Length); if...
22 Nov 2011 by 2011999
Dear Experts, protected void btnUpdae_Click(object sender, EventArgs e) { SqlDataAdapter daq; string connection = System.Configuration.ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString; using (SqlConnection con...
23 Nov 2011 by 2011999
Dear All Experts,In my grid view five columns only two columns or editable mode remaining three colums non editable mode (asp.net,CSharp) but button is taken outside the grid view.Thank u for your valuable replay
25 Nov 2011 by 2011999
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: Line 136:Line 137: //currentTitleOfCourtesy = ((TextBox)r.FindControl("TitleOfCourtesyTextBox")).Text;Line 138: currentLastName =...
25 Nov 2011 by 2011999
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.DataItem != null) { DataRowView drv = (DataRowView)e.Row.DataItem; string catName = Convert.ToString(drv["CategoryName"]); if (catName.Trim() ==...
26 Nov 2011 by 2011999
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;public partial class GridViewCellsEdit : System.Web.UI.Page{ private const int...
28 Nov 2011 by 2011999
grdView.EditIndex = -1; ShowGridBindData(); }I got Error in this line daq.Fill(ds, "db");
28 Nov 2011 by 2011999
Question qs = new Question(); string name = Request.QueryString["UserName"]; TextBox txtQuestionNo = (TextBox)row.FindControl("Question No"); TextBox txtComments =...
29 Nov 2011 by 2011999
Dear All,How to retrive the GridviewRows and how to use these values SQL Update StatementThank for advance, for ur valuable reply
1 Dec 2011 by 2011999
Below line of code not taken values from grid string temp2 = grdView.Rows[i].Cells[3].Text; '> Below line of code not taken...
1 Dec 2011 by 2011999
using System.Configuration;protected void btnUpdae_Click(object sender, EventArgs e){ string connection = ConfigurationManager.ConnectionStrings["QuestionnaireConnection"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); ...
9 Jan 2012 by 2011999
I am using SQL Server 2008R2 Management Studio
28 Jan 2012 by 2011999
Dear All,my quation is one table relation to how many tables related. how to find out table relation. i need how to find out relation through sql command .
30 Jan 2012 by 2011999
Error Message :The SelectCommand property has not been initialized before calling 'Fill'.
30 Jan 2012 by 2011999
Server Error in '/RetriveData' Application.--------------------------------------------------------------------------------Could not load file or assembly 'firebirdsql.data.firebirdclient' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded...
7 Feb 2012 by 2011999
when i am run my program. only first employee details is i got it. i am select second employee not retrive the second employee. only first employee details is retrive it.how i am got selected employee details in my web form. protected void Page_Load(object sender, EventArgs e) {...