Are you talking about fetching a column of data and displaying it as a single row? SQL Server has an interesting command that can do that. STRING_AGG (Transact-SQL) - SQL Server | Microsoft Learn[^]
David Mujica
Posts
-
Fetch row and display in frontend column -
ORDER BY in UNIONI know this is not going to be a popular opinion, but ... 1) Create a #TEMP table 2) Insert into the table with part 1 of the query 3) Insert into the table with part 2 (sorted) Return the dataset from the #TEMP table
-
what is visual basic used forCurrently I use VB for 1) Windows services - Processing file messages into database transactions 2) Schedule data extractions - Monthly SQL extracts, reports, Excel, etc Anything that requires a User Interface, I develop a Web Application, anything that requires background execution I develop in VB. :java:
-
execute an update using --> "Exec sp_executesql @Sql1"How is the @Sql1 variable defined ? Ex: Declare @Sql1 Varchar(200)
-
Get Process PercentageHow about this approach ... 1) Run the process as a test, collecting the total time it takes. Call it "T" 2) Store that run time somewhere 3) Next time you run the process you can now use "T" as the denominator to calculate the percent complete. p = duration_now/T 4) If the percentage calculation goes over 100, then set it 100. 5) Capture the new total time, "T", store it for the next iteration. Rinse, repeat. Not perfect, but it might work for you. :java:
-
Best practice for creating a limited access ms-sql user ?Given: 1) Developing a WebService on a DMZ server which will connect back to corporate SQL2019 server. 2) There are lots of other databases on this server, however there will be only one database (DB_X) which these WebServices need to interact. 3) Assume user, WEBAPI_USER, is created. Also executed: DENY VIEW ANY DATABASE TO WEBAPI_USER; 4) Now, that user cannot see any databases via MS SQL Server Studio, not even the DB_X database which has been granted access Note: Kind of crazy because if you run the query: SELECT * FROM SYSOBJECTS WHERE XTYPE = 'U', you will get a full list of all the tables. If done some research on this and it appears that WEBAPI_USER would need to become the owner of the databaase to see it in MSSS. Question: What is everyone else doing to create a limited access MS-SQL user ? Thank you in advance. David
-
Connecting DB tablesPost your SQL code and table definitions and you should get some help here.
-
I am having problem creating a script to monitor Rest/API services.I see a few problems with your code: 1) Looks like your main() does not call your ServerStatusBy() function 2) You are not reading any values from the command line. Here is a VB example:
Sub Main()
Dim args() As String = System.Environment.GetCommandLineArgs()
Dim s As StringFor i As Integer = 0 To args.Length - 1 Console.WriteLine(String.Format("Arg {0}): {1} ", i, args(i))) Next s = Console.ReadLine End Sub
When you run the program from a command prompt like HellowWorld.exe www.google.com jdoe@companyabc.com The output is as follows: Arg 0): C:\_WorkingCopies\HelloWorld\HelloWorld\bin\Debug\HelloWorld.vshost.exe Arg 1): www.google.com Arg 2): jdoe@companyabc.com You can see that you want to grab Arg(1) as the URL and Arg(2) as the email address you want to send the report.
-
I am having problem creating a script to monitor Rest/API services.Just a thought; what if you pass the URL as a command line argument ? This way the program is agnostic to which server it is checking. You could also pass the email addresses on the command line.
-
Sandwich Query For Employee Attendance using SQL Server 2005A few SQL functions may be of help for you .. Take a look at this query
SELECT *,DATEPART(wk, AttDate) As 'Week Number',DATEPART(weekday, AttDate) As 'Week Day', DATENAME(WEEKDAY,ATTDATE) FROM #TEMP1
-
Import Excel sheet into Gridview and SQLHere is something that I use in my web app ... 1) Define a connection string pointing to the Excel file
String.Format("Provider=Microsoft.ACE.OLEDB.12.0; Data Source = {0}; Extended Properties='Excel 12.0; HDR=Yes; IMEX=1;'", sFilename)
- You can access some schema information from the Excel doc like this ...
DTschema = dbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
- Then get to the actual data in the spreadsheet like this ...
Using dbCmd As New OleDbCommand("SELECT * FROM [" & sSheet & "]", dbConn)
Using dbAdapter As New OleDbDataAdapter(dbCmd)
dbAdapter.Fill(DT)
End UsingIt may not be pretty, but you get the data from the spreadsheet into a datatable which can then be bound to a Gridview. See if it works for you. :thumbsup:
-
Database scripts version control process/strategy?One way to approach this is to have a create a baseline set of scripts which created all of your DB objects: Tables, Indexes, Triggers, Stored Proc, etc. Check those scripts into a version control system () along with your source code. (Make a folder called "SQL" or something) As you revise your application, create ALTER scripts for the DB objects (Tables, Indexes, Triggers, Stored Proc, etc) which will take the database from State A to State B. Use some type of naming convention which will show the progress from one version to another. "ALTER_tables_1.0.0_to_1.0.1" When you get to a major release of the software, such as v2.0.0, then Re-Create the CREATE DB object scripts which will include all of your ALTER scripts; this way you don't have to keep rolling up schema changes. ALSO: Take into consideration that you may need Data Manipulation scripts to "seed" some of your tables with basic data. Handle those scripts with something like ALTER_Data_1.0.0_to_1.0.1 Just giving you some ideas, not completely thought out, but I remember doing something like on previous projects. BTW: I use Subversion / SVN / Tortoise as version control for myself.
-
Dead lock issue with Update and delete statement on the same table -
Generating unique user IDConsider implementing a Sequence table like: SequenceName, NextID The table will consist of a single row such as UserID, 2083928937 This way you immediately know what the next UserID is. Within a transaction, create the User, then update the sequence table by 1. :java:
-
pls helpIf you run your application on the WebServer where it is hosted, you may get more detail about the error without having to do anything else. Try to RDC (Remote Desktop Connection) to that server. :java:
-
Sql server deadlock issue with table bulk insert and update on same tableIf you are using a script to initiate the bulk load, at the end of the script start the process for updating. That is a simple way of synchronizing the processes. :java:
-
Updater for multi-user programI think what you need to research is the topic of concurrency. One way to implement this is to have a Modify Date on the primary record. 1) Read the table entry along with the modify date/time. 2) When updating the database, compare the original date/time with the value currently stored, if the date/time has not been changed, then it is OK to perform your update. (Rollback) During your update you would set the modify date/time to the current date/time. (GetDate() ) Something like that.
-
Reporting dataWhat database are you using? If it is MS-SQL, then there is a command call PIVOT which will do exactly what you want to do. :java:
-
Developing a Restaurant Billing SystemAre you going to integrate it with your kitchen and bar ? Once the order is taken, it should notify the kitchen and bar. When the server picks up the order, it should perform a timestamp on pickup so you can see how long an order takes to process. Just a thought. :java:
-
Create a new Primary Key on survey tableCan you explain what these columns are ? Looks like you have enough data to make a primary key, but understanding the data would lead to a suggestion. :java: