Giter VIP home page Giter VIP logo

Comments (3)

inferrinizzard avatar inferrinizzard commented on June 17, 2024

Can you provide the query that you trying to format ?

from prettier-sql.

RyanGrange avatar RyanGrange commented on June 17, 2024

(Sorry for all the edits you're probably getting emailed. I missed the preview tab initially.)
Any of our stored procedures I try to format with the formatter set to inferrinizzard.prettier-sql-vscode pops up the notification...
Unable to format SQL: TypeError: Cannot read properties of undefined (reading 'value')

Source: Prettier SQL VSCode (Extension)

Here's an example with company specific names removed.

USE [TestDB]
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'TestProc')
BEGIN
	exec('CREATE PROCEDURE [dbo].[TestProc] AS BEGIN SET NOCOUNT ON END;');
	IF SUSER_NAME() != 'testuser' BEGIN
		GRANT EXECUTE ON dbo.TestProc TO testuser;
	END
END
GO

ALTER PROCEDURE [dbo].[TestProc]
AS BEGIN
	SET NOCOUNT ON;

	declare @batchsize int = 5000
		,@timestamp varchar(33)
		,@totalrows int = 0
		,@rowcnt int = 0;

	select @rowcnt = 1, @totalrows = 0;
	while (@rowcnt > 0)
	begin
		delete top (@batchsize) testalias
		from dbo.TestTable testalias
		where testalias.TestDtField < dateadd(day, -31, getutcdate())

		set @rowcnt = @@ROWCOUNT;
		set @totalrows = @totalrows + @rowcnt;
		waitfor delay '00:00:00.5'
	end
	set @timestamp = convert(varchar(33), getutcdate(), 126);
	raiserror ('%s: %i entries deleted', 0, 1, @timestamp, @totalrows) with nowait
END
GO

It did, however, work with a very simple SQL statement:

select * from dbo.TestTable where TestTable.TestDTField > dateadd(day, -7, getutcdate());

->

SELECT *
FROM dbo.TestTable
WHERE
    TestTable.TestDTField > dateadd(DAY, -7, getutcdate());

from prettier-sql.

RyanGrange avatar RyanGrange commented on June 17, 2024

Oh. Crap. I just saw on the home page/readme that it doesn't support stored procedures. I'll give some others a try. Sorry to waste your time on this.

from prettier-sql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.