id_no first_name last_name 1 X ABC 2 Y ABC 3 M pqr 4 N PQR Here is the query I am running : SELECT STUFF((select stuff1 from(SELECT distinct T1.id_no 'sequenceno', ('/' + Col2) + ',' + STUFF((SELECT STUFF2 FROM(SELECT distinct T2.id_no 'sequenceno' ,'-' + substring(first_name, 1, 1)'STUFF2' FROM Table2 AS T2 WHERE T2.last_name = T1.last_name AND T2.id_no = 1234 AND T2.id_no = T1.id_no) dt2 order BY dt2.sequenceno FOR XML PATH(''),TYPE ).value('.', 'varchar(MAX)'), 1, 1, '') 'stuff1' FROM Table1 AS T1) dt order BY dt.sequenceno FOR XML PATH(''),TYPE).value('.', 'VARCHAR(MAX)'), 1, 1, '') AS Result OUTPUT - ABc,X-Y/ABc,X-Y/pqr,M-N/PQR,M-N Desired OUTPUT - ABc,X-Y/pqr,M-N Can you pls help me on this ?
Swap9
Posts
-
SQL server query -
SQL server 12: Displaying column cell values in single cellI had to add few extra condition suitable to my table, but it DID WORK !! :) I have learnt about STUFF and FOR XML PATH. Thanks a ton for all your time Richard.
-
SQL server 12: Displaying column cell values in single cellID Column1 Column2 -- -------- ---------- 7 Vaugh William 7 Vaugh Smith 6 Woods Jane 6 Woods Joseph 6 Wright Adam 6 Wright John Thanks, I exactly put the condition at the place you suggeted, but still the output I get is as below WRONG OP : Vaugh,William-Smith/Woods,Jane-Joseph/Wright, Adam-John Expected OP : Woods,Jane-Joseph/Wright, Adam-John
-
SQL server 12: Displaying column cell values in single cellID Column1 Column2 -- -------- ---------- 7 Vaugh William 7 Vaugh Smith 6 Woods Jane 6 Woods Joseph 6 Wright Adam 6 Wright John Suppose I have to find the combined name only for id=6 , then where should I put the condition in the code? The expected output : Woods,Jane-Joseph/Wright,Adam-John
-
SQL server 12: Displaying column cell values in single cellI am getting the combined names for the whole table. How to restrict it for a single id? Can you please tell where should I put the condition in the code you have shown above ?
-
SQL server 12: Displaying column cell values in single cellI want to display the unique last names followed by their respective first names separated by a '-' and, then '/' , then again the next last name(If it is not distinct , then add their first names separated by '-')followed by its respective firstname and so on..
-
SQL server 12: Displaying column cell values in single cellyes there is just single cell output. but conditions are that cell can not have more than 30 characters. Even there are 10 or 15 rows in a table, the SQL query should give single cell output.
-
SQL server 12: Displaying column cell values in single cellWhat extra information will make it clear ?
-
SQL server 12: Displaying column cell values in single cellColumn1 Column2 -------- ---------- Vaugh William Vaugh Smith Woods Jane Expected Output : Vaugh, William-Smith/Woods,Jane Condition : There could be n number of rows in the sample table, there could be n number of woods too. display all the common surname having different names meaning repeated Last names will be once then all the first names associated with it. truncated at 30 characters max. How can I get this output in SQL query ?
-
'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *'Hello superman...just trying my luck by asking this to you... problem piece of code - if(Function(parm1, parm2, parm3)==0){ error - cannot convert parameter 3 from 'char [1024]' to 'wchar_t *' Function is expecting wchar_t but its getting char[1024] from some where. I changed the function signature to accept wchar_t type in header file. objective is to make the whole code UNICODE enabled. I have added all the tchar.h, wchar.h fiels param 3 has been defined (modified) as wchar_t in all the connected files too. I cant debug yet. Pls help how can i get rid of this error. I am working in vs2010.I counter checked it about five times and gave the search in solution to find if parm3 is still 'char' somewhere else. I am seriously doubting typecasting the wchar_t parm3[] before passing it function i think. I went to function declaration and changed it to char* to wchar_t* too. I doubt that might not be straight forward. there should be some changes.
-
error - cannot convert parameter 3 from 'char [1024]' to 'wchar_t *'problem piece of code - if(Function(parm1, parm2, parm3)==0){ error - cannot convert parameter 3 from 'char [1024]' to 'wchar_t *' parm3 is an array - //char parm3[Buffsize1024]; //was before wchar_t parm3[Buffsize1024]; // I changed to make the application unicode enabled Function is expecting wchar_t but its getting char[1024] from some where. I also changed the function signature to accept wchar_t type in header file. objective is to make the whole code UNICODE enabled. I have added all the tchar.h, wchar.h fiels param 3 has been defined (modified) as wchar_t in all the connected files too. I also tried to cast the string and pass the casted string. CString s(parm3) LPCTSTR p = s; no change in the error. I cant debug yet. Pls help how can I get rid of this error.
-
'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *'However, the swprintf function, which is a VC++ library function is the correct one to use.
The wsprintf function is part of some windows API, and does not support all the formatting options. For example wsprintf does not support the "*" width specification.Thanks !
-
'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *'Worked ! great... thanks :)
-
'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *'I am trying to enable an application for unicode. //char c_buffer[ARRAY]; TCHAR c_buffer[ARRAY]; above are the changes I made into code. Which breaks at this code in the .cpp file sprintf(c_buffer, "%d", pb->i_id); abc.cpp: error C2664: 'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *' Why so ? I have added TCHAR.h and strsafe.h
-
'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *'I am trying to enable an application for unicode. //char c_buffer[ARRAY]; TCHAR c_buffer[ARRAY]; above are the changes I made into code. At this code sprintf(c_buffer, "%d", pb->i_id); abc.cpp: error C2664: 'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *' Why so ? I have added TCHAR.h and strsafe.h If I hover the mouse over the code it tells "argument of type 'TCHAR *' is incompatible with parameter of type'char *'" pls help
-
migration from Visual studio 6Sure, Thanks a lot for responding. I will find out.
-
migration from Visual studio 6Ok thats another approach - but if its easy I can do it. Will you be able to show me a simple example of it ? can I compile and execute it in Japanese just by adding _T() on the Japanese windows ? I had another expert suggesting me this option, but that looked like another proj on its own http://social.msdn.microsoft.com/Forums/vstudio/en-US/d3b75db1-3646-4591-84c5-924cd5ec3065/how-to-change-the-application-to-display-gui-screens-captions-etc-in-both-the-languages-japanese?forum=vcgeneral#a4ff216a-fd6c-419f-a8a5-81b40b08e4b8[^]
-
migration from Visual studio 6I also have another issue - posted at http://www.codeproject.com/Messages/4873177/How-can-I-display-Japanese-characters-in-an-applic.aspx[^] Will be able to help please ?
-
migration from Visual studio 6Thank you so much !
-
migration from Visual studio 6right no warnings when removing __STDC__ stuff. I am trying to resolve where is that disagreement happening - but I am confused looking what is the meaning of these four statement ?
typedef int (*p)(void *, void *);
typedef void *P;
typedef void* P;
typedef void* (*p)();