Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Execute SQL Server Stored Procedures

I would like to execute the below statment using python on sql server. The statment is working on sql sqerver. But when i tried to execute as sql from python it fails. Any idea how to run in directly?!

#sqlserver #storedprocedure --List the DBName, SchemaName, table Name, ROWCOUNT, DATA SIZE --for ALL the database in specific server declare @SprocsTableCount as Table ( dbname varchar(128), SchemaName varchar (128), ObjectName VarChar(128), rowscount int, DataSize int, createddate datetime, modifydate datetime ) insert into @SprocsTableCount execute sp_MSforeachdb N'use [?]; select ''?'' , , ,p.rows ,DataInKB=sum(a.used_pages)*8 ,CreateDate=t.create_date ,ModifyDate=t.modify_date FROM sys.schemas s JOIN sys.tables t on s.schema_id=t.schema_id JOIN sys.partitions p on t.object_id=p.object_id JOIN sys.allocation_units a on a.container_id=p.partition_id GROUP BY,, t.create_date, t.modify_date, p.rows ORDER BY SchemaName, TableName' select dbname as DbName,SchemaName as SchemaName,ObjectName,rowscount as Rows,DataSize as DataInKB ,createddate as CreateDate,modifydate as ModifyDate from @SprocsTableCount order by dbname
please show python code, and where it fails.
@eslamerman the programme structure is mistake. here im sharing brief explaination about execution SQl once look into this , i feel this will helps you.
(Jul-25-2020, 02:07 PM)Larz60+ Wrote: please show python code, and where it fails.
I don't have a python code. I want to know how to execute this using python.
When I execute it from SSMS, it returns a result.

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)