I have a simple database with UserId (int), EmployeeName(Varchar), and 7 fields presenting days of the week.(bit/Boolean). It's function is to keep track of which Employees are available at what day(s) of the week.
What I want is for the user to select 1 of the 7 days in a dropdownlist after which a datagridview shows all employees that have that particular day set "true" so...
SELECT * FROM [EmployeeTable] WHERE [value selected index dropdownlist] = true
Question is how do I place the value of the selected day of the dropdownlist in this query? Or is there a better way to write a Select query?
etc duration is in seconds what i want to be able to do is add the start time from a row to the duration from the same row and sutract it from the next rows startime.
I know this is a very simple problem however I've literally just begun learning about SQL and this is the first ever code i've created using the language.
The error is:
Msg 102, Level 15, State 1, Line 30 Incorrect syntax near ')'. Located on line containing "create table Trailer_Type"
I am new to SQL but I have jumped into it fairly deep. I need to write a query to generate a report that counts systems by the first two characters in the system name and gives a count by the first two characters and a total of all the systems. The first part I have but I cannot think of how to get an overall total. Here is the code I am using: select substring(dm.[Name],1,2) as 'Location', count(distinct dm.[Name]) as '# Discovered', count(distinct w.[Name]) as '# Managed', count(distinct w.[Name])*100 / count(distinct dm.[Name]) as '% Managed' from DiscoveredMachines dm, Wrksta w
where datediff(dd,dm.[DiscoveryDate],getdate()) < 90 and dm.[Name] *= w.[Name] and (dm.[Name] like 'AB%' or dm.[Name]like 'CD%' or dm.[Name] like 'AD%' or dm.[Name]like 'CB%' or dm.[Name] like 'SX%' or dm.[Name] like 'EX%')
I am writing a query to list all users in 2 countries but exclude users which their name starts with _inactive_5#4$66899, holder_....
I wrote
Select position, subsidiaryName from position where subsidiaryname = 'country one' OR subsidiaryname= 'country 2'
I get a result but there are some names which are fake accounts
eg. names start with inactive_#@$%&*ijkgfhg
or with holder_uhgfjgj
how can I do write into the query so that only the proper names without the rows that are fake showing up. In other words i want all results for those 2 countries except ones starting with inactive or with holder......?
First off sorry for my complete lack of experience with SQL, but I've just started a new position which involved learning SQL. I'm currently looking for a course but in the mean time I just have to try and fumble by doing basic things.
I'm trying to write my first basic select / join statement, and I just can't seem to get it working.
Any help would really be appreciated. It's T-SQL we use btw.
Thanks :)
USE MLSDHeat GO
select * from dbo.CallLog where callstatus between 'open'and 'pending' right outer join dbo.Asgnmnt on callid = callid order by callid
--the above returns error Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'right'.
I'm struggling with the problem which feels like it shouldn't be taking me this long! Any help would be gratefully received. Simply, there are two tables: Users: userid | username Links: sourceUserId | destUserId sourceUserId and destUserId are both in the users table. I'm trying to write a SP which will output the names of the linked users. eg: Bob | Alice Alice | Geoffrey Peter | Bob Any help gratefully received! Thanks in advance -- Chris
I am bulk-loading a large amount of data into a group of related tables. Each table has an identity column as its primary key.
A problem is introduced because I need to break up the bulk-loads into multiple sessions, due to performance and memory constraints. I can get all the foreign key references correct within the scope of a single bulk-load session. However, there are many duplicate rows when you look at the job as a whole.
So, I need to find all the duplicate rows, collapse them down to a single row, and update all the foreign key references in other tables to reference this single row.
I can find all the duplicate rows and generate a table consisting of the primary key ids and the duplicated values, ie:
ID Value ---+----- 1 | Fred 2 | Fred 5 | Ethel 7 | Ethel 9 | Ethel
Now, all I need to do is DELETE all the duplicate rows (in the example above, rows 2, 7 and 9) and generate UPDATE statements for the other tables that reference this one which replace all the duplicate keys with the chosen one (ie. replace all references to foreign key 2 with 1, and all references to foreign key 7 and 9 with 5).
But this is where I'm getting stuck with SQL. I haven't been able to figure out a way to extract just the first row for each group of Values, which contains the primary key I will use to substitute, then generate the correct subquery for the UPDATEs.
I know I can do this sort of thing procedurally, but I'm wondering if there is also an elegant way to do this in SQL. Thanks so much for the help!!
So, I have never worked with SQL in my entire life, but have some basic programming skills. I was given a job to run through two tables, sort some of the information and return the two most recent enteries for the job number. I can sort everything but I am having a hard time just returning the two most recent enteries. I have two tables in which to look from and I think a subquery WHERE with the TOP would work.... yet I have tried everything i can think of and after a good 10 hours of research, im hoping to get some help!
The two most recent enteries that i need returned is "start date" with all the other information...
Here is my code that is from designer (which i have played with to no avail)
SELECT Table1.[Inquiry #], Table1.[TTI #], Table1.[Proj Name], Table1.[Customer Name], Table1.[Date In], Table2.Activity, Table2.[Start Date], Table2.[Stop Date], Table2.[Project Lead] FROM Table1 INNER JOIN Table2 ON Table1.[Inquiry #] = Table2.[Inquiry #] GROUP BY Table1.[Inquiry #], Table1.[TTI #], Table1.[Proj Name], Table1.[Customer Name], Table1.[Date In], Table2.Activity, Table2.[Start Date], Table2.[Stop Date], Table2.[Project Lead] ORDER BY Table1.[Inquiry #], Table2.[Start Date] DESC;
Well, all i can do now is pray someone has the opportunity to help.
if the value of a paticular cell in the table has changed since last poll,
then initiate the second task
2. do a select query that picks about 10,000 new rows off another db table,
the 10,000 rows should then be stored in a in-memory dataset.
Every time the poll initiates a new select query, it should insert the new rows to the existing in-memory dataset.
thus if the select runs for 2 times in 2 minutes, the the in-memory dataset would contain a maximum of 20,000 rows.
3. Then I want to apply a set of transformations on the dataset and then finally update some db tables, push some records to the ssas database. (push mode incremental processing)
which sub tasks can be achieved and which cannot.
if not, Is there a workaround?
Please do provide some specific links that accomplish some of these similar tasks.
I have tested some functionality, like
doing a full processing of a ssas database.
reading from a database table and inserting into a flat file.
I tired to use the ExecuteSQLTask, and i also assigned the resultant to an user:variable. the execution completed succesfully but I am not able to see the value of the variable change. also I am not able to use the variable to figure out a change in previous value and thus initiate a sql select. or use the variable to do anything.
Hi there I sorry if I have placed this query in the wrong place. I'm getting to grips with ASP.net 2, slowly but surely! When i try to access my site which uses a Sql Server 2005 express DB i am receiving the following error:
Server Error in '/jarebu/site1' Application.
Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
This is the connection string that I am using: <connectionStrings> <add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;Initial Catalog=ASPNETDB;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings>
The database is definitly in the folder that the error message relates to. What I'm finding confusing is that the connection string seems to be finding "aranga"s database. Is it something daft?
I've been reading a million and one posts on replication
My scenario is that i have a live SQL 2000 server. In a DR invokation, i'e i've lost my live sever, i want to be able to access the same data at the DR (SQL 2000) site and have it accessable to the users. DR server has a different name to the live box.
Replicate
Master CRMDatabase
Data changes all the time but can have hourly replication of transaction logs for this example. I've currently researched a sp called update logons but this has to be fed each account name to enable them on the new server. There must be a way to activate all CRMDatabase logons with the new server?
Could someone be kind enough to lead me through a step by step guide on the best solution.
Hopefully this is the right place to post this, I am trying to learn ADO.Net programming using VWD Express with SQL Express... I tried to do the walk-through tutorial on ADO.Net through the asp.net tutorial. The walk-through asked you to download and install a script (check) then it said to open a command window with sql server running (check) and then to copy all of this special script code into to bind the database to the web page (not check). Everything pretty much went down hill after that part. I couldn't get the Update/Cancel/Delete buttons. After that dissapointing attempt at learning I decided to just try and make my own database. All was going pretty well until I try to add the UPDATE/DELETE fields after adding the WHERE clause. No go. So, I don't know if I'm just totally flubbing this up or if this is a common problem. Do I need the two or three pages of custom script like the Microsoft example to make a database work?
1 Hi, I'm a complete newbie at this, and need some help I want to import a text file into a DB. I know how to set it up in the DTS, however when I check the DB each line from the text file is in a seperate row. What have I missed? I want the file just in one row, like its a memo.
2 What do I use to connect to a SQL DB on the web so i can see the DB and all the tables
3 Also if I want to add data to a DB is that done on the server, or do I change my copy of the DB and re-upload
I've imported an access .mbd table into SQL 7.0, and need to know the best way to overwrite my SQL 7.0 table with the new Updated information that is contained in the access table. I've read a little bit about update tables, but is there an easy way to overwrite an entire table without having to specify each row and column?
Ok, not sure if this is where i should post this, but here goes.
I am trying to setup a database to handle RMA stuff at work. I need to be able to access the DB from numerous systems at once. Now i know NOTHING about SQL or any other DB for the most part. Messed around with Access some, but nothing major.
Is there anyone that could help me, explain how, or at least point me in the right direction?
I have MS SQL server 2000. Any help, ideas, or suggestions would be great!!
Hey! I',m totally new to Ms SQL Server. I'm currently trying to import a database from LINUX using SQL+ (Oracle) to MS SQL Server. Any suggestions on how this could be achieved would be most helpful
I need to know how to write a sql statement for VB to Microsoft Access for the following criteria.
TblEmployees only Field to be concerned with is EmployeeID -Its PK TblEmpAttendane has these fields: EntryID - Pk EmployeeID - Fk Date- A text form date validated through vb to avoid hassle Value-A single digit value that can be alpha OR numeric
To get the Date range for the current month I use variables to store the First and last day of the month(in a CUSTOM calendar control).
I have been trying to use this Sql statement(that wont work): SqlString = "SELECT * FROM TblEmpAttendance WHERE Date BETWEEN '" & FirstDay & "' AND '" & LastDay & "'"
I need to: 1.)using the current EmployeeID (from TblEmployees) 2.) find the same EmployeeID in TblEmpAttendance 3.)Get the date range for the current month and year(valid days currnt mo.) -these date are supplied by the variables "FirstDay" AND "LastDay" as seen in above SqlString
4.) Find the Values associated with the dates and EmployeeID
I have a table with 10 records: 10, 9, 8, 7 ... and so on. I want to SELECT the top 3 records starting with the second record on the list (which in this case is 9.) So the result should be 9, 8, and 7. What would be the correct SQL statement for this?
I tried "SELECT TOP 3 * FROM tableXXX WHERE (FieldID<>(SELECT TOP 1 * FROM tableXXX ORDER BY FieldID DESC) ORDER BY FieldID DESC" but sure as heck it didn't work. Can anyone help?
just for understanding a simple iif statement: I like to set a numeric value to 0, if it is smaller than 0. This expression shall be valid over all dimensions for a specific measure
like Iif([Measures].[Provision Ankauf]<0,0,[Measures].[Provision Ankauf] )
it's not working, Pivottable returns ##VALUE everywhere
I have two problems. I am currently using SQL Server express and SQL Server Management Studio Express locally. i have a DotNetNuke website running on the web with IHostASP.Net
Story:
I noticed that my SQL Server 2005 database with IHostASP.net was 350MB. It was only 22 2 months ago and I have had about 100 users sign up. I then connected to my live database via SQL Server Management Studio Express and shrunk the database. No errors and the database was reduced to 24MB - Great I thought!
I went and checked the website and all was great for about an hour then the site went down with the following error:
Error The transaction log for database 'classcampers' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
Anyone know what to do.
Anyway, I have downloaded a .bak of my database as supplied by my host. However I cant figure out to restore this file back to my live database. What are the steps involved?
Do I create a new local database from the .bak and then somhow restore this back to my live one, or do i apply this .bak file strainght to my live database using SQLMSE. Any tutorials becuase I have been trying to apply this restore all day
Thansk for any advice in advance cheers Albertramsbottom:eek:
Hi, which is current running mostly used version of sql server and what was the previous version? how can we track down a query bad performance in sql server(like explain plan,stats..etc..in oracle)
Ive been learning SQL slowly and I need help for a projet I am doing.
I currently would like to compare identical files in a 2 seperate folder. Not only would I like to compare if the files are the same name, but when they are I would like to compare the file contents.
SO basically this is what I need to do: -Compare file names in folder A with files in folder B -If a match is found, compare file contents -If file contents are same, do nothing. If file contents are different, move file to folder C.
I finally decided to do our ASP application using VB, .NET and MSSQL.
My questions are simple, but I cannot find all the answers, so anything you can offer will be greatly appreciated.
Please explain how licenses (CALS) work with regard to Windows Server and MSSQL. For example, suppose we have 200 clients all logged into our application, but only say 40 are currently active (meaning they are adding data, running reports, etc....), but they are not all clicking the "DO" button at the same time. So how many Windows server and/or MSSQL seats, licenses, CALS, cpu's etc.... (whatever they are called) will I need?
How many users do you think a "well designed" ASP application built using AJAX, ActiveX, VB, .NET and MSSQL can a single cpu reasonably support? This application will serve east coast to west coast with heavy traffic from say 7am to 9am and 2pm to 4pm in each time zone. At what point (or what should I look for) to say, you need more memory, more processors, more servers, etc......????
How does one protect (or build in) a method to deal with index corruptions, etc???? Does that occur in MSSQL? If so, generally, what are causes and fixes?
The application will serve many chapters. Many chapters will be solo (by themselves), but we also expect district wide, where multiple chapters (25 to 75) in one district will use the application. We can expect, during time frames mentioned above, that each chapter will have 200 to 400 transactions per am time and same per pm time.
has anyone had great success with IronSpeed?
Lastly, can anyone suggest some good windows web hosting companies?
Hi i have 2 columns in the same table.....one column retrieves all registered students, the other column retrieved registered students but who have not completed a required survey.
The 2 sql statements are almost the same except that the 2nd one does another comparison at another table....(i.e. where student_id not in (select student_id from other_t).
I am trying to combine the 2 sql statements into a derived table where results will be displayed as follows:
registered students | students(incomplete surveys)
I have a database and in my database there are 5 different tables....
One of the tables is called "dvds" and another one is calles "reports"
What I want to do is, I would like to copy and paste everything in "reports" (column name: dvd) to "dvds" table (column name: name).
And I wan the SQL parameter to check everytime before it writes to "name" column in case that entry is already there. If the entry is already there then ignore and do not write, if it is not there then write it.
I am very sorry about my english and my knowledge on SQL.
Can anyone please help me to product this SQL command?
I have questions regarding theses files TRN, LDF, MDF and BAK.
I have a maintenance plan that backups the .TRN and .BAK everynight in a folder e:/mssqlsrv/MSSQL/Bakup. When I look at the date modified in windows explorer they are exactly like I programmed it in the maintenance plan.
Now when I look in the folder e:/mssqlsrv/MSSQL/Data I see the .LDF and .MDF files and they are way out of date. How do they get copied there? With the maintenance plan? What is the difference between the TRN and the LDF?
How does a restore work? I am so confused? Please explain to me?