yo im new


.
I am new to SQL. Ive browsed t hrough some things and have found SQL is not that difficult to pick up. I have a little experience in python and VB.

atm, I am working on a code for my clan-leader, and trying to build a query.

I am trying to merge two SQL statements, which I know do work.


select _clan_hoa_user.username as Forumname, _clan_hoa_userfield.field11 as SummonerName, _clan_hoa_user.email as email, _clan_hoa_user.skype as skype,FROM_UNIXTIME(_clan_hoa_user.lastpost,'%Y %D %M') as LastPost from _clan_hoa_user, _clan_hoa_userfield, _clan_hoa_usergroup where _clan_hoa_user.userid = _clan_hoa_userfield.userid and _clan_hoa_user.usergroupid = _clan_hoa_usergroup.usergroupid AND _clan_hoa_userfield.field11 != '' AND _clan_hoa_userfield.field20 != 'Yes' AND _clan_hoa_usergroup.title = 'Member' AND _clan_hoa_user.username NOT IN ('Bigifinda','Code47') case WHEN _clan_hoa_user.lastpost = "0" THEN "No Posts" Else FROM_UNIXTIME(_clan_hoa_user.lastpost) < DATE_SUB(NOW(), INTERVAL 7 DAY) ORDER BY LastPost ASC

and

SELECT username, LastPost, CASE LastPost WHEN "0" THEN "No Posts" ELSE "Illegal Argument" END AS "Status" FROM _clan_hoa_user

together. They work seperately, but I am trying to merge them, and it produced this:

select _clan_hoa_user.username as Forumname, _clan_hoa_userfield.field11 as SummonerName, _clan_hoa_user.email as email, _clan_hoa_user.skype as skype,FROM_UNIXTIME(_clan_hoa_user.lastvisit,'%Y %D %M') as LastVisit from _clan_hoa_user, _clan_hoa_userfield, _clan_hoa_usergroup where _clan_hoa_user.userid = _clan_hoa_userfield.userid and _clan_hoa_user.usergroupid = _clan_hoa_usergroup.usergroupid AND _clan_hoa_userfield.field11 != '' AND _clan_hoa_userfield.field20 != 'Yes' AND _clan_hoa_usergroup.title = 'Member' AND _clan_hoa_user.username NOT IN ('Bigifinda','Code47') AND lastvisit( select * when "0" then "No Posts" When FROM_UNIXTIME(_clan_hoa_user.lastpost) < DATE_SUB(NOW(), INTERVAL 7 DAY) from _clan_hoa_user ) ORDER BY LastPost ASC

but I get an error from SQL Fiddle:
Schema Creation Failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select * when "0" then "No Posts" When FROM_UNIXTIME(_clan_hoa_user.lastpost)' at line 9:

I don't want ya to just feed me the answer to this little problem, but something pointed out so i can learn would be nice. I have looked up information on google and w3schools, but have come up dry so far.

edit: and im just just here to get help, ill look around the forum a bit and see what i can learn
Edited by Ancient_Doom, 23 October 2012 - 08:15 PM.
Posted On: Monday 31st of December 2012 01:53:38 AM Total Views:  282
View Complete with Replies

RELATED TOPICS OF Microsoft SQL Server PROGRAMMING LANGUAGE




Pulling Uniquely when you can't use distinct, or an ID

So here is the problem I have a table, with an identity in it, I have another table, with that number, it is a one to many relationship. That table has Fname, Lname inisde of it, some numbers have 1 record, some have 4 Here is the query Code: SELECT FName = ISNULL(UPPER(LTRIM(RTRIM(addr.FName))),'') , LName = ISNULL(UPPER(LTRIM(RTRIM(addr.LName))) ,'') , FName2 = ISNULL(UPPER(LTRIM(RTRIM(names.FName))),'') , LName2 = ISNULL(UPPER(LTRIM(RTRIM(names.LName))) ,'') , FName3 = ISNULL(UPPER(LTRIM(RTRIM(names.FName))),'') , LName3 = ISNULL(UPPER(LTRIM(RTRIM(names.LName))) ,'') , FName4 = ISNULL(UPPER(LTRIM(RTRIM(names.FName))),'') , LName4 = ISNULL(UPPER(LTRIM(RTRIM(names.LName))) ,'') , Address1 = ISNULL(UPPER(LTRIM(RTRIM(addr.Address1))) ,'') , Address2 = ISNULL(UPPER(LTRIM(RTRIM(addr.Address2))) ,'') , City = ISNULL(UPPER(LTRIM(RTRIM(addr.City))) ,'') , State = (SELECT StateAbbr FROM ac_States WHERE StateID = addr.StateID) , addr.Zip FROM Edina_Class class LEFT JOIN Edina_Names names ON names.claimno = class.claimno INNER JOIN Edina_Address addr ON class.claimno = addr.claimno where addr.isactive = 1 What I want is to pull back the unique names, so, if the use only had 1 name, name2-4 would be blank, if the person had 3 names name4 would be blank. Since "name1" is in the address table, I can pull that one back easy, but what is happening, is the code is taking the first name is finds in the name table and filling in names2 - names4 with it. I have no idea how to fix the person besides recreating the name to have all of the names per user in 1 record opposed to individual records in the names table. Hope that made sense.
VIEWS ON THIS POST

103

Posted on:

Friday 26th October 2012
View Replies!

Anyone have sql 7.0 to sell

I really need to buy sql 7.0 standard. Does anyone have license and cd for this. I am in a rush I dont care if it has box or not. My purchasing person bought 7.0 enterprise off of ebay and it showed up today but we cannot install on server 2000,..Please help.
VIEWS ON THIS POST

89

Posted on:

Friday 26th October 2012
View Replies!

Principal schema error

I am sort of new to this and am inheirting the role to maintain a database. In that process I am trying to clean things up adn remove users and adding them to groups to simplify things. on the users name in the login properties they are assigned to one database in the SQL server. I am simply trying to remove that. I am gettign an error that says: " The database principal owns a schema in the database, and canoot be dropped, error 15138) How can I elleviate this I went into the tables in the database and removed the permissions for the user for each of the tables and went in again and their name was gone from the permissions. good But now I want to remove the user from the Security Logins completly. BUt everytime I try this I get the error above. I want to remove the iser from the logins because I know have them assiggned to a group which I will add to the logins to minimize the amount of logins...
VIEWS ON THIS POST

88

Posted on:

Wednesday 7th November 2012
View Replies!

How To Find SQL Server CPU usage when database is online

any one pls let me know 1)how to find the CPU usage, may be through query analyser 2) whats the normal CPU usage 3)Reason why could CPU usage go high 4)How to reduce the CPU usage is high
VIEWS ON THIS POST

139

Posted on:

Wednesday 7th November 2012
View Replies!

Random String Generation

Hi Guys, I am trying to insert a unique code, like a voucher code, into a table in MSSQL, 10 numbers (0-9) which obviously needs to be unique. I can code this in ASP, but I think the process could be a bit long winded, i.e. create a key - run a stored procedure to see if it is free if not loop. Surely there would be a way to do this in a stored procedure in one So the key would look like 3928492834. 1. Generate Key in SQL 2. Check if not used in column 'kcode' if it is, regenerate and check again. Any advice would be greatly appreciated, I know how to do this in ASP but bit of a SQL newbie!
VIEWS ON THIS POST

33

Posted on:

Wednesday 7th November 2012
View Replies!

Integration Service - One question...

I wrote/built the whatever objects on the Integration Service (DTS or Data Transformation Service). There is one thing I couldn't figured out.. If I use the "Execute SQL Task" to get the two values in minimum year and maximum year. Then how can I use them to go with the 'Where' clause within the SQL Command (Query) to the "DataSource Reader" object It doesn't look like it is possible so instead, what object should I use that will make this possible
VIEWS ON THIS POST

98

Posted on:

Wednesday 7th November 2012
View Replies!

DTS Package run but job fails

I am able to run DTS packages in sequence manually. But when i try to run the job,i get the following message: Error string: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. Error source: Microsoft OLE DB Provider for SQL Server Help file: Help context: 0. Process Exit Code 1. The step failed. It is confirmed that DSN is proper and SQL server name is also correct.Still wondering why this error occured Please advise.
VIEWS ON THIS POST

104

Posted on:

Wednesday 7th November 2012
View Replies!

How to match an alphanumeric string data in a field?

I would like to return a total number of records from a table in which their 'inMessage' field matches the a string with a format like this, eg. 55 213 aaa 58 Can anyone tell me how shall i write the sql statement Code: SELECT COUNT(*) AS Total FROM Inlog WHERE Message LIKE '\t' What shall i put as my comparison parameter
VIEWS ON THIS POST

131

Posted on:

Wednesday 7th November 2012
View Replies!

Yes/No data type on microdoft sql ?!?!

hi , which data type i have to choose for the field , if i would like to make it only Yes or No 0 for no , 1 for yes!
VIEWS ON THIS POST

70

Posted on:

Wednesday 7th November 2012
View Replies!

Check for double records

I want to find out if I have got double records (same value in column "headline") in my table. I there a easy query or do I have to work with temp.tables and store procs regards. Raggi
VIEWS ON THIS POST

76

Posted on:

Saturday 10th November 2012
View Replies!

Edit binary type in open rows page

Hi well I know that it is a little funny but I don't know how to edit the binary type variables from right click on table and open rows most of the time I have to use query analyzer to do this to insert or update the table but I need to work in a real table
VIEWS ON THIS POST

122

Posted on:

Saturday 10th November 2012
View Replies!

Problem with DTS Script - please help!

Hi all, Please can anyone help me with this When I run the following script in SQL Server I get the error "Microsoft VBScript compilation error, expected 'Function', line 35. Line 35 is the line with the IF statement, so that is obviously the problem, but I have done exactly the same thing before with another script and it works. The datatypes of the source and destination are the same, the lengths are different obviously. Any ideas '************************************************* ********************* ' Visual Basic Transformation Script ' Copy each source column to the ' destination column '************************************************* *********************** Function Main() DTSDestination("Prac_Code") = DTSSource("Practice Code") DTSDestination("Name") = DTSSource("Practice") DTSDestination("List_Size") = DTSSource("List Size") DTSDestination("PCG") = DTSSource("PCG") DTSDestination("Add1") = DTSSource("Address1") DTSDestination("Add2") = DTSSource("Address2") DTSDestination("Add3") = DTSSource("Town") DTSDestination("Add4") = DTSSource("BOROUGH") DTSDestination("Pcode") = DTSSource("Post Code") DTSDestination("Tel") = DTSSource("Tel") DTSDestination("Fax") = DTSSource("Fax") DTSDestination("Premises_Note") = DTSSource("PremisesNote") DTSDestination("PMS") = DTSSource("PMS") DTSDestination("PMS_Notes") = DTSSource("PMS Notes") DTSDestination("Note") = DTSSource("Note") DTSDestination("Num_Prncpls") = DTSSource("No of Prncpls") DTSDestination("Rent") = DTSSource("Rent") DTSDestination("Ave_per_WTE") = DTSSource("Ave per WTE") DTSDestination("Num_Sal_GP") = DTSSource("No Sal GPs") DTSDestination("Vacancies_WTE") = DTSSource("VacanciesWTEs") DTSDestination("Type_Rent") = DTSSource("Type of Rent") DTSDestination("B_Type_Rent") = DTSSource("BType of Rent") DTSDestination("Branch_Rent") = DTSSource("Brent") DTSDestination("Out_of_Hours") = DTSSource("OOH") DTSDestination("WTE_Detail") = DTSSource("WTE Detail") DTSDestination("WTE_Date") = DTSSource("WTEDate") DTSDestination("Train_Practice") = DTSSource("TrgPract") If DTSSource("Branch") = "Yes" then DTSDestination("Branch") = "Y" End If If DTSSource("Branch") = "No" then DTSDestination("Branch") = "N" End If DTSDestination("Branch_Add1") = DTSSource("Baddress1") DTSDestination("Branch_Add2") = DTSSource("Baddress2") DTSDestination("Branch_Add3") = DTSSource("Btown") DTSDestination("Branch_Pcode") = DTSSource("Bpost code") DTSDestination("Branch_Tel") = DTSSource("BTel") Main = DTSTransformStat_OK End Function Thank you !
VIEWS ON THIS POST

90

Posted on:

Saturday 10th November 2012
View Replies!

What datatype?

What is the difference between int and numeric I want to have a datatype storing number 1 to 20. What datatype should I use (int or numeric(2)) I want to store timestamp - what should be the datatype Sanjay Masawan sanjaym@bsil.com
VIEWS ON THIS POST

86

Posted on:

Saturday 10th November 2012
View Replies!

Compare ADO, OLE DB, ODBC, SQLHELPER

I am a newbie to database, I read there are many connection ways such as ADO.NET, OLE DB, ODBC, SQLHELPER. What are their difference in connecting to a MS SQL 2000 What criteria to decide to use which one
VIEWS ON THIS POST

53

Posted on:

Saturday 10th November 2012
View Replies!

Calculate totals with group by

Hi I have not been using SQL Server very long and i am totally stuck on what is possibly quite a simple query assuming it is possible. I have a single table that i wan to query, it is a database of songs with all the usual fields Artist, Title, Album, Duration etc. What i need to do is calculate the total track time for each artist so i end up with... Artist Duration Artist1 625549876 Artist2 882655489 etc. The durations are all stored as integers in milliseconds but all i need is the total duration for each artist. Anyone give me a clue on how to achieve this.
VIEWS ON THIS POST

117

Posted on:

Sunday 11th November 2012
View Replies!

Query to find out which columns have 5% null values?

Helping a friend out (or trying to). He has a problem where he has a table with 1300 columns. What he needs to find is of those 1300 columns, which have 5% or greater with a value of null (does that make sense, im not sure...) example. Column ABC has 5 rowsthat are null out of 100 rows, so he would need the query to return "ABC"...hopefully that cleared it up. Like I said, the table is 1300 columns and approximately 2,000,000 rows, so its impractical to do one at a time...any ideas
VIEWS ON THIS POST

143

Posted on:

Sunday 11th November 2012
View Replies!

ASP/ SQL Programming Neophyte

Greetz, I'm REALLY fresh to dealing with ASP and dynamic webprogramming in general. I have an issue right now that I was hoping one or some of you on this forum would be able to assist me on. I am looking to connect to generate two webpages. The first webpage is to display all entries that exist in a SQL Database (but not all the rows that exist for that entry). Assigned to each entry will be a unique number (primary key). The user will be given a chance to enter a number into one section of the page and this in turn would bring up a new page that displays ALL the rows of information that pertain to the number the user inputed. There is only one Database housed on the SQL server being used. Here is the code that I have been using thus far:
VIEWS ON THIS POST

33

Posted on:

Sunday 11th November 2012
View Replies!

Copy database diagram

Hi , I have created an database diagram in one database which I would like to copy to another database. I have managed to export the of dtproperties table to the new database. good, but ... Initially when I open the diagram, all the relationships I have drawn between tables are there, but as the diagram loads further, they all dissapear. I need them to be there also in the newly copied diagram. Any ideas why this is happening
VIEWS ON THIS POST

74

Posted on:

Sunday 11th November 2012
View Replies!

delete duplicate records

hi..... is it possible\t company_id is identity coulmn..so both rows has unique value in this fields..in company_name field both rows have same value(means duplicate values)...other fields may or may not has same values...so can we write a such query which is base on company_name field and we delete duplicates record...............thanx DELETE FROM company_master WHERE (company_id NOT IN (SELECT MIN(company_id) FROM company_master GROUP BY company_id, company_name, catalogue, website, login, password, logo, printad, subscription_date, expiry_date, record_date, update_date, userid, approved, catalogproduct_count, organisation_description))
VIEWS ON THIS POST

109

Posted on:

Sunday 11th November 2012
View Replies!

SQL to XML via Web

Hi Gods, I came with an ideia to put in the environment here... I am trying to put online chart data, so when someone would like to see the data, will just click and the data will be the same as in the database. So i have dig around the net and found a tool to grab .XML and pass the values to a chart, kinda interesting: http://www.maani.us/xml_charts/index.php So, my doubt is... is this possible to have a link to query the MS SQL database, filter the necessary data, output as XML and let the XML Charts do all the rest I found this information so: http://mdid.org/mdidwiki/index.phpt...er_2000_to_XML I think this will help me a lot...but as I dunno too much about the environment I am getting in, I am lookin for some 'yes' or 'no' or some code adaptation to find a good solution : ) Any help will be very welcome.
VIEWS ON THIS POST

43

Posted on:

Sunday 11th November 2012
View Replies!

Getting Up to Speed

I just got a website that supports SQL Server 2000 (7.0). Looking for some good info on getting started with that. Have been developing with DB2 for about 10 years in a corporate environment, and MySql for fun in off-hours. Have read many posts in many places and was envious of those using T-SQL... I have is a web interface to this DB, not installed locally. Any and all info for a starting point with SQL Server will be most appreciated. Quite interested in how stored procs are used/syntax,etc.
VIEWS ON THIS POST

33

Posted on:

Sunday 11th November 2012
View Replies!

Retrieving Files from sql server

Does anyone have any ideas as to how I could extract a file (.pdf) which is stored in a sql server table and save it in a file system The pdf's need to be stored in the database so that I can restrict access to them to their respective client. I need to pull them out and temporarily store them in a file system so that they can be attached to an email message using cdosys. The pdf would then be instantly deleted from the file system.
VIEWS ON THIS POST

135

Posted on:

Sunday 11th November 2012
View Replies!

Indexes

What makes the difference between the below two create index statements\t\t In my scenario, the second create index statement is giving me better performance. Conceptually, what is difference\t Why do we go for INCLUDE clause in the CREATE INDEX statement create index on (c1,c2,c3,c4,c5) create index on (c1,c2,c3) include (c4,c5)
VIEWS ON THIS POST

26

Posted on:

Monday 12th November 2012
View Replies!

Access to Sql Server Question

have several access databases that are linked to the same backend Access database.* I am in the process of converting all these databbases to SQL server 2000.* I have converted the backend database which contains all the tables to SQL Server.* In an Access database you can link only the tables you want and you can create separate queries in each front end database.* I have a lot of quereis in each database and some have the same name but do different things. When you have an Access project you get everything from the SQL database - tables, views \t.everything.* I have thought about creating a separate SQL database for each of my applications.* I would have a primary database that contained all the tables, etc and then a separate database that contained only views of the tables in my primary database.* That way I could copy a lot of my quereis directly to each respective SQL database. Example: Primary database Table Name:*Authors Human resources database View Name: Authors with the sql "Select * from pubs.dbo.authors" If I did it this way then I could copy most of my Access quereis directly to SQL server and have seperate queries and sp's for each application. I would also have my quereis seperated for each application. If I didn't use views then I would have to recreate all my queries which would be a pain because I have a lot of queries based on other queries and would to come up with another naming convention if I wanted to id queries for each application. I have though about just linking the tables and views to a regular Access database but I would prefer to use a project. Is using views in this way a good idea or a bad idea Are there any major drawbacks
VIEWS ON THIS POST

36

Posted on:

Thursday 15th November 2012
View Replies!

how do i know which user is entering data?

i am currently working on a cinema website which requires users to book tickets. i have managed to link the website to my database and currently have a robust password and joining page(s) workin with the database.however once the user has logged in how do i know which user is purchasing cinema tickets this is achieved through sessions but they are not working.
VIEWS ON THIS POST

109

Posted on:

Thursday 15th November 2012
View Replies!

Combine multiple rows into 1 row

its peebman2000 beginner programmer. I have completed and asp.net web form that is storing data into SQL Server 2005. I'm needing to right a query to show multiple rows in 1 row so I can give my client a spreadsheet of the stored data. These are my tables: Customertable: id/f_name /l_name 1/ Peebman/ 2000 2/ Alex / Smith class table: id/classname 1/Social studies 2/English 3/Math Idtable (composite table) Id/customerid/classid/onwaitlist 1 / 2 / 2 /null 2/ 2 / 3 / yes 3/ 1 / 1 /yes I need a query to show my data like this: f_name/l_name /class1 /class2 / class3 /onwaitlist peebman/2000/social studies/null / null /yes class1 Alex / smith/ null /English /Math /yes class3 Does anyone have any suggestions on a query I could use to display my data this way. Below is a query I kind of put together from what I found online, but its not giving me what I want. Code: Select distinct name, class1, class2, class3, class4, class5, class6 from (Select usr.f_name +' '+ usr.l_name as name, case when class.id = 1 then class.class end as class1, case when class.id = 2 then class.class end as class2, case when class.id = 3 then class.class end as class3, case when class.id = 4 then class.class end as class4, case when class.id = 5 then class.class end as class5, case when class.id = 6 then class.class end as class6 From ocbacademy2007_2 usr, ocb_academyclass_2 class, ocbacademyid_2 lnk where usr.id = lnk.personid and class.id = lnk.class_id) as new It gives me this: [highlight="Sql table"]name class1 class2 class3 class4 class5 class6 Peebman2000 NULL NULL NULL NULL WOOC: 3:00pm-5:00pm NULL Peebman2000 NULL NULL NULL OPRS: 1:30pm-3:00pm NULL NULL Peebman2000 NULL NULL WOOC: 10:30am-12:30pm NULL NULL NULL Peebman2000 S.U.E.: 9:00am-4:30pm NULL NULL NULL NULL NULL [/highlight] Does anyone have any suggestions, I would appreciate the help so much,
VIEWS ON THIS POST

90

Posted on:

Monday 19th November 2012
View Replies!

Update rows on the base of sum records

Im working on small project I stacked with sql query in sql server 2005. Ive nearly 5 thousands records with one field money data type. My question is how to update only those records which are cost less then 1k and not more than 50 k. Is there any way to write a simple query to update records on given above conditions For example: Name Cost(money data type) update(Ill update here) A 500 ---- B 1200 ---- C 999 ---- D 800 ---- Etc till 5000 rows, there should be some value in the name and cost column. If 1k records are less then 50 nos.. how many are there, weve to update those records If 1k records are more then 50. then weve take first 50 and remaining not to do anything If its near 49.5k like that, that time also not a problem. Im looking forward for your help. mdateeq2003
VIEWS ON THIS POST

199

Posted on:

Tuesday 20th November 2012
View Replies!

Insert 500 numbers...

i got 500 numbers...example: 123, 223, 222, 522...etc i want to perform an INSERT.... how can i loop the numbers or anyway will do... to avoid replacing the number one by one for the Insert statement... Please advise....
VIEWS ON THIS POST

90

Posted on:

Tuesday 20th November 2012
View Replies!

DTS Question

I have 3 seperate databases on a server. Internal_1 Between_2 External_3 I replicate from 1 to 2 easily. But i want to create a DTS package that's only updates 3. I have tried my best but i guess it's not good enough. Code: '********************************************************************** ' Visual Basic Transformation Script '************************************************************************ ' Copy each source column to the destination column Function Main() DTSDestination("InvType") = DTSSource("Invoice Type") DTSDestination("InvNo") = DTSSource("Invoice No") DTSDestination("Pid") = DTSSource("Practice Id") Main = DTSTransformStat_UpdateQuery End Function I ca't figure out how to get this working.
VIEWS ON THIS POST

52

Posted on:

Tuesday 20th November 2012
View Replies!

Where to Install SQL Server for best performance

Install SQL Server for best performance I currently have a .net application that uses SQL server 2000 svcpk3a as the back end to a custom .net application. My question is where should I install the SQL Server, SQL Data, and the .net web app to get the best performance. Meanwhile server 2003 Enterprise, iis, and the .net frame work is installed on the crive. My server hardware is configured as follows: HP Proliant 360 (2) Dual Core Xeon processors 8Gb of memory (6) Hard drives total- (2) setup as mirrored drives on separate controller that makeup the C:drive (4) setup as RAID drives on separate controller that makeup the drive So with this configuration should I install my sql server application on the C:drive and place the sql data on the drive. Also where should I place the actual web app. On the C:drive with the ISS and .net installation or on the drive ***Install option 1*** C:drive (2) mirrored drives iis and .net frame work .net application D:drive (4) RAID drives SQL Server application SQL Data ***Install option 2*** C:drive (2) mirrored drives iis and .net frame work SQL Server application D:drive (4) RAID drives .net application SQL Data Respectfully, David
VIEWS ON THIS POST

106

Posted on:

Tuesday 20th November 2012
View Replies!

Ms Sql 2000

attach db MS SQL 2000 with enterprise manager I have a file de db sqlserver 2000 called hello_db_20060410man.bak my last host has transfered to me i am not hosted anymore and trying to attach my sqldb to use on IIS on my computer but...... enterprise manager asks me for files in .mdf and .log i have been trying and searching for 3 days... How can I transform this .bak \t when i try to restore. enterprise message is that this ,bak is not a sql file !!! anyone could help please ! sorry for my english... and on top i am lost and beginner
VIEWS ON THIS POST

210

Posted on:

Tuesday 20th November 2012
View Replies!

favorites table creation

I am developing an application where the user will have the option of having favorites of service providers.. It is a child table with 2 columns, both of them will be foreign keys, the one column is a foreign key from the favorites table to a table that holds credentials(username/password), this will mark the user. The other column is a foreign key to the service providers table, this will mark the service provider, the one that is favorite to the specific user. Here we have a many to many relationship. And the problem comes from the fact that what happens when a user has more that one favorite. That means multiple values to the service provider column of the favorite table-this column is of the INT type. I know that this violates the principle of atomicity of RDBMS-I cannot find an alternative though. What can I do in such a case
VIEWS ON THIS POST

44

Posted on:

Saturday 29th December 2012
View Replies!

SQL Server 2008: How to export SQL data to CSV file with headers using BCP

I created a simple Stored Procedure (SP) that queries a table and renames the column names, and I'm able to push those results out to a CSV file *with* those header names when done manually. But when I try to export the results to a CSV file by running the same SP using xp_cmdshell with bcp, the header row (Col1, Col2, and Col3) does not appear in the resulting CSV file. ORIGINAL TABLE: ColumnName1-----ColumnName2-----ColumnName3 Joe Schmo Customer Jane Doe Customer Tim Tiny Musician QUERY WITHIN SP: SELECT ColumnName1 AS Col1, ColumnName2 AS Col2, ColumnName3 AS Col3 FROM TABLENAME QUERY RESULT: Col1-----Col2-----Col3
VIEWS ON THIS POST

256

Posted on:

Sunday 30th December 2012
View Replies!