Click here to Skip to main content
15,888,035 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 Updated

SQL Server 

18 Apr 2010 by #Jet
i am trying to generate a dynamic where clause in my store proc.=== @population nvarchar(max)declare @chvSelect varchar(max), @chvFrom varchar(max), @chvWhere varchar(max), @chvOrderby varchar(max), @chvSQL...
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.
22 Jan 2010 by #realJSOP
You need to establish two connections - one to each server.
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...
1 Feb 2010 by #realJSOP
This is NOT an appropriate question.
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...
15 Mar 2010 by #realJSOP
Using Sql Manager Express (free util from MS), export your database to a script, and then...0) Embed the script as a resource in an appropriate assembly.1) When your program starts up, try to connect to the database.2) If it's not there (the SqlConnection.Open() method throws an...
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’)
23 Mar 2010 by #realJSOP
I found this exchange with google:WPF's DataGrid is a bit different than ASP.net's DataGrid. One way you can export to excel with WPF's DG is to use the DataGrid.CopyToClipboard command which makes a copy in a CSV, html, and text format. From there you can either just create a csv file or...
29 Mar 2010 by #realJSOP
You need an integer column in the table that is set as the primary key and auto-incrementing (an "identity" column).
3 Apr 2010 by #realJSOP
select * from students where subjectnumber = 100 or subjectnumber = 220It ain't rocket science.
13 Apr 2010 by #realJSOP
You could use a completely separate select statement for it.
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
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...
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...
7 Jul 2010 by #realJSOP
If you already have the connection string, just split the string like so:string[] parts = connectionString.Split(';'); and then iterate through the parts array until you find the part that starts with "Data Source=".string dataSource = "";for (int i =0; i
19 Jul 2010 by #realJSOP
Your question makes little sense. If you are asking if you can get aweb serive's settings from a database in order to communicate with the web service, yes you can, but only if that database can be accessed without the use of the web service. Typically, a web service can only be accessed...
25 Jul 2010 by #realJSOP
The unique ID merely identifies the record. Your assumption that one song can only be attributed to a single artist is flawed because many artists might cover the same song. For instance, I know of at least a dozen versions of the title Ghost Riders In The Sky, and some of those versions are...
10 Aug 2010 by #realJSOP
You've already identified the solution - create a windows service. Go forth and code.
26 Aug 2010 by #realJSOP
When you retrieve it, have the stored procedure strip the character from the strings, or when you save it, strip the character before you update the database.
1 Sep 2010 by #realJSOP
I don't really understand what you're asking.Each table has its own identifier column that's set up as the primary key for that table. If you want to prevent dupliccate info in the 2nd table, your have to design your database in such a way as to setup relationships using the identifier...
9 Sep 2010 by #realJSOP
Put the query into a stored proc, and pass the necessary parameters into that stored proc.
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).
14 Sep 2010 by #realJSOP
I'm willing to bet your str param is empty/null.Using the debugger will really help. Honestly. It's already installed on your system (it comes with Visual Studio).
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.
24 Sep 2010 by #realJSOP
0) Don't combine several different non-related questions in a single question.1) Google is your friend.
4 Oct 2010 by #realJSOP
You can't possibly be serious. Questions and Answers is not meant for this type of "question". It's to ask for help on a specific programming problem you're having.
5 Oct 2010 by #realJSOP
I found this using googl (gak! I know! google! who'd a thunk it?!)http://www.codenewsgroups.net/aspnetwebcontrols/t10235-determining-which-control-has-focus-web-page.aspx[^]
6 Oct 2010 by #realJSOP
If I understand your question correctly, you want to start the update, and then show progress messages every 10 seconds.You could make the stored proc that's doing the update write a status indicator of some kind to a table, and from a thread in your app, check that status indicator every 10...
6 Oct 2010 by #realJSOP
A liitle googling goes a long way. Googling the phrase "finding depenecies between tables and stored procedures" came up with 13 results, and this was one of...
6 Oct 2010 by #realJSOP
Google return 992 THOUSAND results for the phrase "max number of columns sql table", and this was the first link:http://msdn.microsoft.com/en-us/library/ms143432.aspx[^]
11 Oct 2010 by #realJSOP
Padding your resume with lies will get you nowhere. If you can't answer questions that will be asked, you'll just come away looking like an idiot, and worse, someone that can' t be trusted. That means your "career" will be in the dumper before you even start.Learn how to write a resume, and...
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...
7 Dec 2010 by #realJSOP
You need to learn how to use google first.
13 Dec 2010 by #realJSOP
Try closing the connection AFTER retrieving the output parameter.
15 Dec 2010 by #realJSOP
Google really is the first place you should look. I googled "database connection with VB.Net", and this was the first of over 1.8 MILLION results:http://www.homeandlearn.co.uk/net/nets12p4.html[^]
16 Dec 2010 by #realJSOP
You could easily have found this using google.select top 2 * from tableEDIT =========================This was the original text which I responded to:Hi I am new to .net i have to get two rows of data from sqlserver table and i have to add both rows how can i get rows from table...
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...
20 Dec 2010 by #realJSOP
Your userID and password are incorrect, or maybe your SQL server instance isn't configured to allow TCP/IP connections.
20 Dec 2010 by #realJSOP
Two things you can consider:0) You could lock the record being modified when someone requests the data, and then when a 2nd user requests it while the record is locked, make the edit fields read-only. Put a refresh button on the form and allow the user to re-request the data until he can put...
24 Dec 2010 by #realJSOP
You could google "improve sql server performance", and gave in awe at the prospect of weeding through over 4.6 MILLION results. Among them, you will find this one:http://msdn.microsoft.com/en-us/library/ff647793.aspx[^]And just in case your question was actually about .Net applications...
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...
31 Dec 2010 by #realJSOP
You still need those things because your next job may require their use. My current job requires both LINQ and SQL connection stuff.
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".
5 Jan 2011 by #realJSOP
You can also enclose your column name in brackets, like so: [Create Date]
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...
9 Jan 2011 by #realJSOP
First, you're retrieving something you call accountname, but after retrieving it, I don't see where you're using it in the next statement. Second, I would do this for the 2nd line:Int64 value;if (Int64.TryParse(cmb_Subgroupmobiles.SelectedValue.ToString(), out value){ ...
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
That's because Click-Once deployment is a web-based deployment strategy.http://msdn.microsoft.com/en-us/library/t71a733d(v=vs.80).aspx[^]
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.
12 Jan 2011 by #realJSOP
0) The stored procedure doesn't have to be re-written if you refactor the code to a different language, leading to ease of maintenance, and even a certain amount of portability.1) If you need to, you can use the database from additional platforms by simply writing the front end.2) You...
14 Jan 2011 by #realJSOP
You can setup a FTP server on the server machine, and give each client an account to upload files. .Net has a FTP object you can use as well.
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
exec storedproc_name @param1, @parm2, etc...
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 Jan 2011 by #realJSOP
Are you doing something like this:http://support.microsoft.com/kb/307283[^]
20 Jan 2011 by #realJSOP
Columns have no specific order, so retrieving them by index would be a) pointless, and b) unpredictable.
20 Jan 2011 by #realJSOP
0) If any of those text boxes are empty, your code will fail.1) You really should put a try/catch block around the whole thing.2) Is it failing, or are you just here asking if the code looks alright?
25 Jan 2011 by #realJSOP
select * from tablewhere table.DateColumn >= @StartDate AND table.DateColumn
27 Jan 2011 by #realJSOP
Google "t-sql insert update table". Essentially, you'll need a minimum of two statements in a stored procedure, and dpending on whether you're updating existing data or inserting new data, you'll want to use update or insert, whichever is appropriate.
9 Feb 2011 by #realJSOP
The ID is most likely automatically incremented. If you start monkeying around with the value (which I don't think SQL will allow you to do anyway), you will screw up the internal counter and risk a collision. Just leave them alone.
10 Feb 2011 by #realJSOP
.Net is .Net, it doesn't matter what language you use. All of the same framework features are available to all languages. Pick the one you're most comfortable in, and start writing code. As for designing a database, try searching google with the phrase "how to design a SQL database".
14 Feb 2011 by #realJSOP
Make sure it's configured to allow remote access.
18 Feb 2011 by #realJSOP
I'm pretty sure that you should have gotten an email regarding the article when it was deleted.
28 Feb 2011 by #realJSOP
There are more elegant ways, but tyhis should work:declare @whereClause varchar(64)set @whereClaus = ''if (@SortType='A') begin set @whereClause = 'where TopicDelete=0 ' endelse if (@SortType='B') begin set @whereClause = 'where TopicDelete=1 ' ...
1 Mar 2011 by #realJSOP
I want a database of product category, sub category and so on.Ahhh, ambiguous requirements... You must be in management. Hire a programmer. Not only are we NOT going to do this for you, but like Kieth said, we can't, and for the reasons he already stated.
17 Mar 2011 by #realJSOP
try this:set @qry='select '+cast(@count as varchar(32))+' = count(*) from '+@TName;
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...
21 Mar 2011 by #realJSOP
You can't call connection close until after you've read the data from the SqlDataReader object. If you haven't already, put your code in a try/catch/finally block, and close the connection in the finally portion.
31 Mar 2011 by #realJSOP
Does the user need/have an account on the server in question (not in sql, but on the box itself)?
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...
18 Apr 2011 by #realJSOP
Google. Learn it. Live it.http://msdn.microsoft.com/en-us/magazine/cc163473.aspx[^]
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...
4 May 2011 by #realJSOP
Would it be possible to simply transfer the table as a binary file using FTP or TCP/IP, and then let the remote machine do all the database work itself?If you want to ensure some kind of recovery system (in the event the transfer is interrupted), you could send smaller files and alt least...
6 May 2011 by #realJSOP
http://www.asp.net/web-pages[^]
9 May 2011 by #realJSOP
Because it's required to make it work. That's the best I know to tell you.
11 May 2011 by #realJSOP
http://www.connectionstrings.com/sql-server-2005[^]
16 May 2011 by #realJSOP
You don't "switch between layers". The layers are intended to abstract those functional parts out from each other.
17 May 2011 by #realJSOP
Google reveals all:http://www.wisdombay.com/articles/article000014.htm[^]That was the first result of over 32 MILLION returned with this search phrase:.net deploy website with setup file[^]
23 May 2011 by #realJSOP
SELECT SYSDATETIMEOFFSET()Google reveals all...
26 May 2011 by #realJSOP
When all else fails, fire off some events and bask in the glow of the IDE's Progress tab.
2 Jun 2011 by #realJSOP
I have a dynamic query (that works) in a stored procedure. It gets N records starting at record number X from a larger set of records. I now need to return the count of the larger set of records to the calling application, and I don't want to have to create another stored proc to do it.I...
2 Jun 2011 by #realJSOP
I ended up doing this: sp_mySP( parameters..., @totalRecords int OUT)asbegin -- the query string essentially looks like this (comments added for clarity): set @queryStr = -- drop temptable if it exists + 'if #temptable exists drop #temptable; ' -- gets...
3 Jun 2011 by #realJSOP
You can do this:exec(@sql)or this:exec sp_executesql @sql
9 Jun 2011 by #realJSOP
Why would you want to do that? If the stored procedures are already in the database, there's no reason to export them to their own files. You're completely defeating the purpose of having the stored procedures IN the database.
13 Jun 2011 by #realJSOP
There's really no way around slugging it out from scratch. Every customer has his own bizarre ideas about how it should work and what it should look like. The best you can do is to keep the various layers as separated as possible. Write a basic db schema, a business layer to interact with it,...