1
vote
3answers
30 views

Dynamic SUM() while using Sum(Case) on a VIEW in MSSQL

I am trying to create a VIEW where I should have the following columns: Clinic_id | Result_month_id | AVF | AVC | AVG | Other | Total_Days Total_Days should be calculated dynamically using ...
5
votes
1answer
38 views

group by for summary data

Trying to do something here to create a kind of summary data. I'm not sure it will be the most elegant of sql code! I have the following table Product Channel Sold ...
2
votes
2answers
40 views

T-SQL(MSSQL 2005)Reorder Scope_identity

Have a small table of 2 columns on MSSQL Server 2005 which contains a lot of information let's say about 1 billion records and it is constantly being written into. Definition of the table is : ...
1
vote
3answers
45 views

What to use? View or temporary Table

I have a problem to decide whether to use a view or a temp table. I have a stored procedure that i call from program. In that SP i store the result of a long query in a temp table, name the columns ...
1
vote
3answers
62 views

Removing duplicated postcode entries

Basically I've extracted all the streets for London which has over 500000+ records. The database is using SQL Server 2008. For some streets it has put them in correctly such as 'ABBEY TERRACE' and ...
-2
votes
0answers
17 views

Uloading file into Path and folder using sql server with foreign Keys But Dont Know The Error

public partial class Form16UL : System.Web.UI.Page { private SqlConnection con = new SqlConnection("Data Source=DDDDD-pc;Initial Catalog=TAX;Integrated Security=True"); protected void ...
0
votes
1answer
79 views

reducing insert statement time when dealing with large amount of data

I read about SqlBulkCopy and the way it can reduce the amount of time used when inserting large amount of rows my scenario is : I have a an excel file wish I convert it into a dataTable then I send ...
1
vote
2answers
36 views

Can many Users open a SP with a TempTable in it?

After a user is logged into his system and opens my progamm he can see data from a database depending on his WindowsUsername(I wrote a little stored procedure for that). This Data comes from a query ...
1
vote
2answers
45 views

What is better create new table or add columns in existing table

In my database, i have payment table paymentid, amount, duedate, approvalcode, status, transactionid etc. payment table has already 15 columns. if i want to store tip, tax, disount against ...
2
votes
4answers
43 views

Create temp table from another temp table in Dynamic Query

I try to create #temp table from another #temp table then it's through the error. Set @Query = 'Select Work_Order_No,ServiceCode,StageNo,ItemWeight,StagePercentage,FebLocation INTO #TempMaster ...
0
votes
2answers
18 views

SQL Server 2008 R2 Pivot issue

I have a Table1 shown here: This table has column called duration type which can have value as "YTD" or "MTD" Now I want my table after doing a select using Pivot to look like the one shown in the ...
2
votes
4answers
66 views

Is there any way to group by a text column?

I have this code: select CAST(OPERATOR_NAME AS NVARCHAR(MAX)) as 'Utilizador', TERMINAL_DESCRIPTION as 'Terminal', DOCUMENT_DATE as 'Data de Inicio', PAYMENT_LIMIT_DATE as 'Data de Fim', ...
2
votes
4answers
31 views

How to migrate SQL data and keep SP's

I have two databases LIVE and DEVEL. I am currently working in DEVEL and have created and modified a number of stored procedures however I am running out of test data so I need to find a way to copy ...
0
votes
2answers
35 views

is it possible to find out how much of the db data is older than some N years in SQL Server?

I have two database in SQL Server. I wanted to find out the data older than (let say 3) years. I know the database creation date, currently I have around 550 GB (both the database) of data spanned ...
0
votes
1answer
48 views

SQL Query with Powershell - Return Values not maching

So I have some code I wrote to take the input form a text file and run some sql checks against another database I populated: $volOutput = gc C:\Users\<user>\Desktop\mutant.txt foreach ($m in ...
0
votes
2answers
27 views

SQL use distinct on only one specific field

How can I select only one line by shortDesc field? I don't care about which line, but only I need only one line. My table extract would be |longDescr|shortDesc| |---------|---------| | First 1 | ...
0
votes
1answer
40 views

Inner join of multiple dynamic select statements

Hello i need to extract common data by applying inner join which is obtained on each loop in @sql variable.I want to apply inner join on result obtained by first loop on @sql to second and so on.For ...
3
votes
3answers
77 views

How to select column names from multiple tables in SQL server 2008 by avoiding certain columns which reoccur in all tables

I have a database that stores the complete details of the employees of a firm. I need to select column names from multiple tables in the database which when executed would provide me the columns ...
0
votes
1answer
32 views

sql query to insert rows from one record in one table into the same table with slight modifications [closed]

I have an sql server table in which i have 30 columns I need to know if the following can be done or not I need to write an sql qyery to copy records in the table into the same table with the 28 ...
0
votes
2answers
66 views

incrementally updating SQL rows

I'm currently dealing with two tables. One table contains a set of columns like ID, NAME, AGE, TEAM, SCHOOL, and so forth in a table called PRIMARY_TABLE And I also have an audit table called ...
0
votes
1answer
23 views

divide two SUM of Two interval

I have a query that return 24 rows. I want to divide SUM of tirst 12 index into SUM next 12 index. I use ROW_NUMBER like this but I can't filter row. How I can do this? SELECT ROW_NUMBER() OVER(ORDER ...
2
votes
1answer
30 views

CASE WHERE change operator - TSQL

I was wondering if you could do a case statement in the WHERE clause which changes the operator. What I am trying to do is filter out results based on a boolean value. SELECT * FROM table1 WHERE ...
0
votes
0answers
26 views

How Can I create a fresh copy of a large database on SQL Server? [migrated]

I have a very large database 400GB that is now corrupted. I tried reparing it with repair_allow_data_loss option but that did not fix the problem so my next option is to restore to a previous version. ...
0
votes
2answers
33 views

how can I update sql server table with new data from an excel sheet?

I have managed to get data from an excel sheet into my SQL SERVER table through VB.net but every time I run the query (click the button), the same data is uploaded again to my table. Is there a way to ...
2
votes
1answer
40 views

Values controlled by foreign keys

I have very simple database in SQL Server, with these three tables: Theater (ID, is3D, othervalues...) Show (ID, Theater_ID, Movie_ID, date, time, othervalues...) Movie (ID, is3D, othervalues...) ...
-1
votes
0answers
51 views

SQL Server default value not set from C#

I defined a default value for the column [Time] and set it to getdate(), and when I insert a row manually in SQL Server it works perfectly fine and insert now date time. BUT when use following ...
0
votes
1answer
66 views

T-SQL stored procedures

I have a table Users with the following columns: Userid Username Password 1 Username1 Password1 2 Username2 Password2 3 Username3 Password3 There is another ...
0
votes
1answer
37 views

How to save wildcard characters in SQL Server NVARCHAR column

Can anyone suggest a workaround to save/retrieve/fetch wildcard characters as part of string in SQL Server? Can anyone suggest a link to list/database of all SQL Server wildcard and commands so that a ...
3
votes
4answers
55 views

WHERE to check if NVARCHAR record begins with a number or symbol in SQL

I am using a SQL statement to fetch records where name begins with some alphabet SELECT * FROM Music WHERE Title LIKE 'A%' ORDER BY Title Can anyone suggest SQL query which will fetch Title ...
-2
votes
2answers
28 views

trigger to allow multiple updates

I have this trigger I want to make it allow multiple row updates, currently it handling only single row update.when i update record, it says sub query returning more then 1 value.. GO ALTER ...

1 2 3 4 5 871
15 30 50 per page