sql-server

Specific day of current month and current year from date time SQL Server 2005

Hello everyone i want search data from invoices and client by today date I'm using DateDiff() GETDATE() functions for example two tables 1 Client - ID int - Name Varcher 2 Invoice - ID int - ClientID int - date Datetime - Total money query Select * from client c inner join invoice i on c.id = i.ClientID WHERE DateD...

SQL Server 2005 metadata search to get stored procedure parameters

How do you get a list of the input parameters for a stored procedure using metadata in SQL Server 2005? I want to do a SELECt on it and then iterate through the variable names. ...

How do I BULK INSERT with additional column showing filename?

Hey there, I'm still getting used to SQL, so before I get to using stored procedure, I would like to understand how to use BULK INSERT effectively first. I need to combine 50+ csv files and dump them into an SQL table. The problem is, I'd like to be able to tell each record apart (as in, each record belongs to a certain csv file, which...

I need a SQL statement that returns the number rows in a table with a specific value.

I'm sure this will equate down to the use of the COUNT statement but I'm not very good at SQL. Here are my SQL Tables. Teams Table: TeamId TeamName RosterSpots ----------------------------------------------- 1 Miami Heat 12 2 New York Knicks 10 Players Table: PlayerId PlayerName ...

Updating "Hierarchyid" in SQL Server

I've used Hierarchyid data type in one of my tables in SQL Server. Now I want to change the father of one of the rows, but when I change that all its descendant HierarchyId's must change according to that. Is there a function to do that or I must change all of them myself. If I need to do that, what is the best way ? Thanks In advance...

MySQL, MS SQL Server or Oracle for large size database, calculation, depth analysis, and graph?

I just come to use database management system and have no experience with all the DBMS programme. For those expert who have experience all the three platform, your opinion on this is very much appreciated. Please guide and let me know the pros and cons. I been doing my database in Excel and would like to continue in other platform despi...

SQLBulkCopy for bulk move of data

Hi All, Im trying to move data in bulk from oracle to sql server. Both source and destination table has the same structure. One of the field is msgtimestamp and the rest are number and varchar field. Im getting the following error when bulkcopy.WriteToServer is called for doing bulk move "The given ColumnMapping does not match up with...

Is it practical to maintain a remote database using scripts only

A current highly strict policy situation is making us consider updating a remote database server via scripts only - having no access via remote desktop connection or such. We will send the scripts and database owners will apply them.. There will be a dedicated dba on the other hand responsible for the maintenance of the databse. This d...

"Named Pipes Provider, error: 40 - Could not open a connection" error after Auto update happens

while trying to connect to remote sql server i got this error. "Named Pipes Provider, error: 40 - Could not open a connection" but for the same server i can connect from other machine. earlier it was working fine for my machine but after automatic update happens on my machine, i got this error. please help me out thanks . ...

Storing ampersand in database

I am currently working with an sql 2008 database. Many of the entries have ampersands stored thusly 'Arts & Culture' Should we be storing the escaped version in the database? Any thoughts much appreciated. ...

SQL Server Reporting Services 2008 - run reports from console app

Hi, I've like to be able to run reports from a console application. The reason I need to do this is because we have a single template with a few params and many reports running off that template - each providing different arguments. It is easier for us to schedule a console app and have the report arguments read from a database. How ca...

ASP.net why are these queries not executing?

In my code neither of these queries appear to be running. The debug label is printing as "end" so it is executing something inside that code block, just appears it doesn't like the queries? // Check input is all valid if (Page.IsValid) { debug.Text = "begin"; using (SqlConnection cn = new SqlConnection( ConfigurationMan...

Database Surrogate Key Name: Product.ProductId vs Product.Id vs Product.Product_Id

Say you have a table named Product and it has an auto-number/identity column. Do you name it simply Id or do you name it ProductId or Product_Id? Please explain why. ...

installation requirements to run SSIS and DTS packages in a job

Hi, my requirement is as follows. the SSIS and DTS packages are stored on the webserver (not in database) and I need to execute them on click of a button on an ASP.NET web page and be able to abort them (again by user action) if they hang for some reason. user doesn't have access to sql server management studio or enterprise manager. if ...

Apply a Mask to Format a String in SQL Server Query/View

Is there a neat way to apply a mask to a string in a SQL Server query? I have two tables, one with Phone number stored as varchar with no literals 0155567890 and a phone type, which has a mask for that phone number type: (##) #### #### What is the best way to return a string (for a merge Document) so that the query returns the fully f...

More efficient way of querying for this data?

I have a table with some data in it: ColA | ColB | ColC ------+------+------ 1 | A | X 2 | A | Y 3 | B | Y 4 | C | Y 5 | C | Z 6 | D | Y 7 | D | Z I want to query to get all of the rows where ColB and ColC as a pair match a condition: SELECT * FROM [Table] WHERE (ColB = A AND...

Are there glitches with trying to use SQL Server Management Studio 2008 R2 to manage MSSQL 2005 DB instances?

I'm currently using Microsoft SQL Server Management Studio ver. 9.00.4035.00 to manage my SQL Server 2005 (90) compatible databases. Will I encounter problems should I attempt to upgrade the Management Studio software to SQL Server Management Studio 2008 R2 to manage MSSQL 2005 DB instances? I will not be upgrading the version of the da...

Serving an Image stored in a database on an aspx page

I'm pulling back an image that is stored in a column in a SQL server database. I need to serve this up on an aspx page. How would I do that? ...

mssql Stored Procedure permissions problem

Hello, I am testing the permissions in mssql and run into a problem. I've made a 'Countries' table and a 'spCountries' Stored procedure. Now I've made a user 'silverlight' and gave it no rights to the Countries table. The user can execute the stored procedure. Now when I do a Select it fails like it should, but in a exec spCountries, a...

How do I display the name from one sql table linked by an id?

bit of a newbie to mvc. i am having trouble with the following scenario: I have a view with the following: <tr> <% foreach (var game in (IEnumerable<Game>)ViewData["Game"]) { %> <td> <input type="checkbox" name="selectedObjects" value="<%=game.Id%>" /> </td> <td> ...